Commit 5be6c1ec by Patryk Czarnik

pierwsze testy pytest

parent 58b42eb2
......@@ -15,11 +15,16 @@ def zdanie_palindrom(napis:str) -> bool:
return palindrom_v2(napis.replace(' ', '').lower())
while True:
napis = input('Podaj napis: ')
if not napis:
break
if zdanie_palindrom(napis):
print(f'Napis "{napis}" jest palindromem')
else:
print(f'Napis "{napis}" nie jest palindromem')
def main():
while True:
napis = input('Podaj napis: ')
if not napis:
break
if zdanie_palindrom(napis):
print(f'Napis "{napis}" jest palindromem')
else:
print(f'Napis "{napis}" nie jest palindromem')
if __name__ == '__main__':
main()
# 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")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment