Advertisement
gruntfutuk

test_classPerson

Mar 23rd, 2018
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.96 KB | None | 0 0
  1. import unittest
  2. import textwrap
  3. from classPerson import Person
  4. from classPerson import Person_str
  5.  
  6.  
  7. class TestPerson(unittest.TestCase):
  8.  
  9.     def test_peter(self):
  10.         print('Testing ...')
  11.         peter = Person("Peter", "male", job="teacher",
  12.                        phone="1234345", height=1.65)
  13.         peter_text = '''\
  14.                        'name': 'Peter'
  15.                        'sex': 'male'
  16.                        'job': 'teacher'
  17.                        'phone': '1234345'
  18.                        'height': 1.65
  19.                        '''
  20.         peter_text = textwrap.dedent(peter_text)
  21.         self.assertEqual(repr(peter), peter_text)
  22.  
  23.     def test_mary(self):
  24.         mary = Person("Mary", "female")
  25.         mary_text = '''\
  26.                        'name': 'Mary'
  27.                        'sex': 'female'
  28.                        '''
  29.         mary_text = textwrap.dedent(mary_text)
  30.         self.assertEqual(repr(mary), mary_text)
  31.  
  32.     def test_john(self):
  33.         john = Person("John", "male", hobby="painting",
  34.                       weight=60, favorite_language="python",
  35.                       nationality="USA")
  36.         john_text = '''\
  37.                        'name': 'John'
  38.                        'sex': 'male'
  39.                        'hobby': 'painting'
  40.                        'weight': 60
  41.                        'favorite_language': 'python'
  42.                        'nationality': 'USA'
  43.                        '''
  44.         john_text = textwrap.dedent(john_text)
  45.         self.assertEqual(repr(john), john_text)
  46.  
  47.     def test_wendy(self):
  48.         print('Testing ...')
  49.         peter = Person_str("Wendy", "female", job="teacher",
  50.                            phone="1234345", height='1.35')
  51.         peter_text = '''\
  52.                        'name': 'Wendy'
  53.                        'sex': 'female'
  54.                        'job': 'teacher'
  55.                        'phone': '1234345'
  56.                        'height': '1.35'
  57.                        '''
  58.         peter_text = textwrap.dedent(peter_text)
  59.         self.assertEqual(repr(peter), peter_text)
  60.  
  61.     def test_barry(self):
  62.         mary = Person_str("Barry", "male")
  63.         mary_text = '''\
  64.                        'name': 'Barry'
  65.                        'sex': 'male'
  66.                        '''
  67.         mary_text = textwrap.dedent(mary_text)
  68.         self.assertEqual(repr(mary), mary_text)
  69.  
  70.     def test_helen(self):
  71.         john = Person_str("Helen", "female", hobby="painting",
  72.                           weight='40', favorite_language="python",
  73.                           nationality="USA")
  74.         john_text = '''\
  75.                        'name': 'Helen'
  76.                        'sex': 'female'
  77.                        'hobby': 'painting'
  78.                        'weight': '40'
  79.                        'favorite_language': 'python'
  80.                        'nationality': 'USA'
  81.                        '''
  82.         john_text = textwrap.dedent(john_text)
  83.         self.assertEqual(repr(john), john_text)
  84.  
  85.  
  86. if __name__ == "__main__":
  87.     unittest.main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement