def testAgeInYearNoParam(self): person = Person('Ivan Ivanov', date(1901, 1, 1)) res = person.age_in() expect = datetime.now().year - 1901 self.assertEqual(res, expect)
def testAgeInFloat(self): person = Person('Ivan Ivanov', date(1901, 1, 1)) with self.assertRaises(ValueError): person.age_in(1.25)
def testAgeInYearMinus(self): person = Person('Ivan Ivanov', date(1901, 1, 1)) with self.assertRaises(ValueError): person.age_in(-1900)
def testAgeIn(self): person = Person('Ivan Ivanov', date(1901, 1, 1)) self.assertEqual(1, person.age_in(1902))