Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import unittest
- def get_formated_name(first, last, middle =''):
- """dupa"""
- if middle:
- sklejone = first + ' ' + middle + ' ' + last
- else:
- sklejone = first + ' ' + last
- return sklejone.title()
- print('Ciskaj q jak chcesz skonczyc progam')
- while True:
- imie = input('Podaj swoje imie')
- if imie == 'q':
- break
- nazwisko = input('Podaj swoje nazwisko:')
- if nazwisko == 'q':
- break
- print(get_formated_name(imie, nazwisko))
- class NameTestCase(unittest.TestCase):
- """ Sprawdzonko czy funkcja get_formated_name działa prawidłowo, po otrzymaniu imienia i nazwiska"""
- def test_imie_nazwisko(self):
- """Czy dane w postaci Janis Joplin sa obslugiwane prawidlowo?"""
- formatted_name = get_formated_name('janis', 'joplin', 'jop')
- self.assertEqual(formatted_name, 'Janis Jop Joplin')
- unittest.main() #nakazanie pythonowi wykonanie testów zawartych w pliku
- ____________________________________________________________________________________________________
- import unittest
- def city_functions(city, country, population=''):
- """funkcja łaczaca miasto i panstwo w jeden string"""
- if population:
- linked = city + ', ' + country + ' - populacja ' + population
- else:
- linked = city + ', ' + country
- return linked.title()
- class Test_1(unittest.TestCase):
- """Testowanie czy format miasta i państwa jest ok"""
- def test_city_country(self):
- tested_values_1 = city_functions('santiago', 'chile')
- self.assertEqual(tested_values_1, 'Santiago, Chile')
- class Test_2(unittest.TestCase):
- """Testowanie czy format miasta i państwa jest ok"""
- def test_city_country(self):
- tested_values_2 = city_functions('santiago', 'chile', '5000000')
- self.assertEqual(tested_values_2, 'Santiago, Chile - Populacja 5000000')
- unittest.main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement