def test_out_of_range(self): self.assertRaises(ValueError, lambda: parse_datetime('Date(2013,12,1,0,0,0)')) self.assertRaises(ValueError, lambda: parse_datetime('Date(2013,-1,1,0,0,0)')) self.assertRaises(ValueError, lambda: parse_datetime('Date(2013,-1,1,24,0,0)'))
def test_month_zero(self): """ the javascript notation uses 0-based months. """ p = parse_datetime('Date(2013,0,1,0,0,0)') expected = datetime(2013, 1, 1, 0, 0, 0) assert_that(p, equal_to(expected))
def test_invalid_format(self): self.assertRaises(ValueError, lambda: parse_datetime('date(2013,1,1,0,0,0)')) self.assertRaises(ValueError, lambda: parse_datetime('Dat(2013,1,1,0,0,0)'))
def test_regular_date(self): p = parse_datetime('Date(2013,11,18,15,41,31)') expected = datetime(2013, 12, 18, 15, 41, 31) assert_that(p, equal_to(expected))