def test_round_to_hour(self): tests = ( ( datetime(2014, 1, 1, 11, 11, 11), datetime(2014, 1, 1, 11, 0, 0) ), ( datetime(2014, 6, 18, 12, 25, 59), datetime(2014, 6, 18, 12, 0, 0), ) ) for test, expected in tests: self.assertEqual(round_to_interval(test, 'hour'), expected)
def raises(): t = datetime(2014, 1, 1, 11, 11, 11) return round_to_interval(t, 'year')
def test_round_to__multiple(self): t = datetime(2014, 1, 1, 11, 11, 11) self.assertEqual(round_to_interval(t, 'hour', 2), datetime(2014, 1, 1, 10, 0, 0)) self.assertEqual(round_to_interval(t, 'minute', 15), datetime(2014, 1, 1, 11, 0, 0)) self.assertEqual(round_to_interval(t, 'minute', 5), datetime(2014, 1, 1, 11, 10, 0)) self.assertEqual(round_to_interval(t, 'minute', 10), datetime(2014, 1, 1, 11, 10, 0))