def test_wrapper_methods(self): p = BusinessPeriod(years=1, months=1, days=1) self.assertEqual(p.add_years(p.years).add_months(p.months).add_days(p.days), BusinessPeriod(years=2, months=2, days=2)) self.assertEqual(p * 2, BusinessPeriod(years=4, months=4, days=4)) self.assertEqual(BusinessDate.add_period(BusinessDate('20160110'), BusinessPeriod(days=-1)), BusinessDate('20160109'))
def test_add(self): p = BusinessPeriod(years=1, months=2, days=3) self.assertRaises(TypeError, lambda: p + 2) p = BusinessPeriod(years=1, months=2, days=3) self.assertEqual(p.add_months(1), BusinessPeriod(years=1, months=3, days=3)) self.assertEqual(p.add_years(10), BusinessPeriod(years=11, months=3, days=3))
def test_wrapper_methods(self): p = BusinessPeriod(years=1, months=1, days=1) self.assertEqual( p.add_years(p.years).add_months(p.months).add_days(p.days), BusinessPeriod(years=2, months=2, days=2)) self.assertEqual(p * 2, BusinessPeriod(years=4, months=4, days=4)) self.assertEqual( BusinessDate.add_period(BusinessDate('20160110'), BusinessPeriod(days=-1)), BusinessDate('20160109'))