def test_constructor(self): """Test constructor. (10p)""" firstname = "Teemu" lastname = "Teekkari" money = 1000 age = 30 human_object = Human(firstname, lastname, money, age) returned_firstname, returned_lastname = human_object.return_name() returned_amount = human_object.return_money() returned_age = human_object.return_age() self.assertEqual( money, returned_amount, """Your costructor or method return_money() doesn't work correctly. Intializing object with money={} and calling method return_money should return {} not {}""" .format(money, money, returned_amount)) self.assertEqual((firstname, lastname), ( returned_firstname, lastname ), """Your costructor or method return_name() doesn't work correctly. Method return_name() returned {}, {}.\n It should have been returned {}, {}""".format(returned_firstname, returned_lastname, firstname, lastname)) self.assertEqual( age, returned_age, """Your costructor or method return_age() doesn't work correctly. Method return_age() returned {} not {}""" .format(age, returned_age))
def test_increment_age(self): """Test method increment_age(). (5p)""" age = 30 times_incremented = 5 human_object = Human("Teemu", "Teekkari", 1000, age) for i in range(times_incremented): human_object.increment_age() returned_age = human_object.return_age() self.assertEqual( age + times_incremented, returned_age, """Method increment_age() doesn't work correctly. After calling method once age should be {}. Your method returned {}.""" .format(age, returned_age))