Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
kurs_alx_pcz
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Patryk Czarnik
kurs_alx_pcz
Commits
5be6c1ec
Commit
5be6c1ec
authored
Nov 30, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pierwsze testy pytest
parent
58b42eb2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
1 deletions
+27
-1
palindrom.py
dzien6/przyklady_funkcji/palindrom.py
+6
-1
palindrom_testy.py
dzien6/przyklady_funkcji/palindrom_testy.py
+21
-0
No files found.
dzien6/przyklady_funkcji/palindrom.py
View file @
5be6c1ec
...
@@ -15,7 +15,8 @@ def zdanie_palindrom(napis:str) -> bool:
...
@@ -15,7 +15,8 @@ def zdanie_palindrom(napis:str) -> bool:
return
palindrom_v2
(
napis
.
replace
(
' '
,
''
)
.
lower
())
return
palindrom_v2
(
napis
.
replace
(
' '
,
''
)
.
lower
())
while
True
:
def
main
():
while
True
:
napis
=
input
(
'Podaj napis: '
)
napis
=
input
(
'Podaj napis: '
)
if
not
napis
:
if
not
napis
:
break
break
...
@@ -23,3 +24,7 @@ while True:
...
@@ -23,3 +24,7 @@ while True:
print
(
f
'Napis "{napis}" jest palindromem'
)
print
(
f
'Napis "{napis}" jest palindromem'
)
else
:
else
:
print
(
f
'Napis "{napis}" nie jest palindromem'
)
print
(
f
'Napis "{napis}" nie jest palindromem'
)
if
__name__
==
'__main__'
:
main
()
dzien6/przyklady_funkcji/palindrom_testy.py
0 → 100644
View file @
5be6c1ec
# W najprostszych przypadkach w kodzie nie trzeba importować modułu pytest,
# ale by udało się uruchomić testy, trzeba zainstalować pakiet pytest, który NIE JEST częścią biblioteki standardowej Pythona.
# W terminalu: pip install pytest
# Ale my zrobimy to przez Pycharm: File > Settings > Project ??? > Python interpreter
# Tworzenie testów jednostkowych, które mają być uruchomione za pomocą pytest,
# polega na napisaniu funkcji:
# - których nazwa rozpoczyna się od test
# - i w których za pomocą assert sprawdzamy, czy oczekiwane warunki są spełnione
from
palindrom
import
*
def
test_kajak
():
assert
palindrom
(
"kajak"
)
==
True
def
test_baba
():
assert
palindrom
(
"baba"
)
==
False
def
test_kobyla
():
assert
zdanie_palindrom
(
"Kobyła ma mały bok"
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment