def test_encode_time(self): result = unit.encode_time(2006, 1, 15, 12, 6, 0) self.assertEqual(result, 159019560.0)
def test_offset(self): u = Unit("hour") v = u.offset_by_time(unit.encode_time(2007, 1, 15, 12, 6, 0)) self.assertEqual(v, "(3600 s) @ 20070115T120600.00000000 UTC")
def test_no_unit(self): u = Unit("no unit") emsg = "Failed to offset" with self.assertRaisesRegex(ValueError, emsg), suppress_errors(): u.offset_by_time(unit.encode_time(1970, 1, 1, 0, 0, 0))
def test_no_unit(self): u = Unit('no unit') msg = 'Failed to offset' with self.assertRaisesRegexp(ValueError, msg), unit.suppress_errors(): u.offset_by_time(unit.encode_time(1970, 1, 1, 0, 0, 0))
def test_encode_time_pass_0(self): result = unit.encode_time(2006, 1, 15, 12, 6, 0) self.assertEqual(result, 159019560.0)
def test_no_unit(self): u = Unit('no unit') emsg = 'Failed to offset' with six.assertRaisesRegex(self, ValueError, emsg), suppress_errors(): u.offset_by_time(unit.encode_time(1970, 1, 1, 0, 0, 0))
def test_offset(self): u = Unit('hour') v = u.offset_by_time(unit.encode_time(2007, 1, 15, 12, 6, 0)) self.assertEqual(v, '(3600 s) @ 20070115T120600.00000000 UTC')
def test_offset_by_time_fail_3(self): u = Unit('no unit') self.assertRaises(ValueError, u.offset_by_time, unit.encode_time(1970, 1, 1, 0, 0, 0))
def test_unit_unknown(self): u = Unit('unknown') msg = 'Failed to offset' with self.assertRaisesRegexp(ValueError, msg), unit.suppress_errors(): u.offset_by_time(unit.encode_time(1970, 1, 1, 0, 0, 0))
def test_offset_by_time_pass_0(self): u = Unit("hour") v = u.offset_by_time(unit.encode_time(2007, 1, 15, 12, 6, 0)) self.assertEqual(v, "(3600 s) @ 20070115T120600.00000000 UTC")
def test_offset_by_time_fail_2(self): u = Unit("unknown") self.assertRaises(ValueError, u.offset_by_time, unit.encode_time(1970, 1, 1, 0, 0, 0))