martaczaska

testowanie python

Jul 9th, 2021 (edited)
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.03 KB | None | 0 0
  1. import unittest
  2.  
  3. def get_formated_name(first, last, middle =''):
  4.     if middle:
  5.         sklejone = first + ' ' + middle + ' ' + last
  6.     else:
  7.         sklejone = first + ' ' + last
  8.     return sklejone.title()
  9.  
  10. print('Ciskaj q jak chcesz skonczyc progam')
  11.  
  12. while True:
  13.     imie = input('Podaj swoje imie')
  14.     if imie == 'q':
  15.         break
  16.    
  17.     nazwisko = input('Podaj swoje nazwisko:')
  18.     if nazwisko == 'q':
  19.         break
  20.    
  21.     print(get_formated_name(imie, nazwisko))
  22.    
  23. class NameTestCase(unittest.TestCase):
  24.     """ Sprawdzonko czy funkcja get_formated_name działa prawidłowo, po otrzymaniu imienia i nazwiska"""
  25.     def test_imie_nazwisko(self):
  26.         """Czy dane w postaci Janis Joplin sa obslugiwane prawidlowo?"""
  27.         formatted_name = get_formated_name('janis', 'joplin', 'jop')
  28.         self.assertEqual(formatted_name, 'Janis Jop Joplin')
  29.        
  30.        
  31. unittest.main() #nakazanie pythonowi wykonanie testów zawartych w pliku
  32.        
  33.        
  34.        
  35.        
  36.        
  37.        
  38.        
Add Comment
Please, Sign In to add comment