Advertisement
martaczaska

teściki

Jul 9th, 2021
1,082
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.00 KB | None | 0 0
  1. import unittest
  2.  
  3. def get_formated_name(first, last, middle =''):
  4.     """dupa"""
  5.     if middle:
  6.         sklejone = first + ' ' + middle + ' ' + last
  7.     else:
  8.         sklejone = first + ' ' + last
  9.     return sklejone.title()
  10.  
  11. print('Ciskaj q jak chcesz skonczyc progam')
  12.  
  13. while True:
  14.     imie = input('Podaj swoje imie')
  15.     if imie == 'q':
  16.         break
  17.    
  18.     nazwisko = input('Podaj swoje nazwisko:')
  19.     if nazwisko == 'q':
  20.         break
  21.    
  22.     print(get_formated_name(imie, nazwisko))
  23.    
  24. class NameTestCase(unittest.TestCase):
  25.     """ Sprawdzonko czy funkcja get_formated_name działa prawidłowo, po otrzymaniu imienia i nazwiska"""
  26.     def test_imie_nazwisko(self):
  27.         """Czy dane w postaci Janis Joplin sa obslugiwane prawidlowo?"""
  28.         formatted_name = get_formated_name('janis', 'joplin', 'jop')
  29.         self.assertEqual(formatted_name, 'Janis Jop Joplin')
  30.        
  31. unittest.main() #nakazanie pythonowi wykonanie testów zawartych w pliku
  32.        
  33.        
  34.  
  35. ____________________________________________________________________________________________________
  36.  
  37. import unittest
  38.  
  39. def city_functions(city, country, population=''):
  40.     """funkcja łaczaca miasto i panstwo w jeden string"""
  41.     if population:
  42.         linked = city + ', ' + country + ' - populacja ' + population
  43.     else:
  44.         linked = city + ', ' + country
  45.     return linked.title()
  46.    
  47.  
  48. class Test_1(unittest.TestCase):
  49.     """Testowanie czy format miasta i państwa jest ok"""
  50.     def test_city_country(self):
  51.         tested_values_1 = city_functions('santiago', 'chile')
  52.         self.assertEqual(tested_values_1, 'Santiago, Chile')
  53.        
  54. class Test_2(unittest.TestCase):
  55.     """Testowanie czy format miasta i państwa jest ok"""
  56.     def test_city_country(self):
  57.         tested_values_2 = city_functions('santiago', 'chile', '5000000')
  58.         self.assertEqual(tested_values_2, 'Santiago, Chile - Populacja 5000000')
  59.        
  60. unittest.main()      
  61.        
  62.        
  63.        
  64.        
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement