Beispiel #1
0
 def test_coerce_rejects_non_utc_timezone(self):
     t = xso.Time()
     with self.assertRaisesRegex(
             ValueError, "time must have UTC timezone or none at all"):
         t.coerce(
             pytz.timezone("Europe/Berlin").localize(
                 datetime(2014, 1, 26, 20, 40, 10)).timetz())
Beispiel #2
0
 def test_coerce_rejects_date(self):
     t = xso.Time()
     with self.assertRaisesRegex(TypeError, "must be a time object"):
         t.coerce(datetime.utcnow().date())
Beispiel #3
0
 def test_coerce_accepts_utc_timezone(self):
     t = xso.Time()
     v = time(20, 40, 10, tzinfo=pytz.utc)
     result = t.coerce(v)
     self.assertEqual(v, result)
Beispiel #4
0
 def test_coerce_accepts_naive_timezone(self):
     t = xso.Time()
     v = time(20, 40, 10)
     result = t.coerce(v)
     self.assertEqual(v, result)
Beispiel #5
0
 def test_format_naive_microseconds(self):
     t = xso.Time()
     self.assertEqual("19:40:10.1234", t.format(time(19, 40, 10, 123400)))
Beispiel #6
0
 def test_format_timezoned_microseconds(self):
     t = xso.Time()
     self.assertEqual("19:40:10.1234Z",
                      t.format(time(19, 40, 10, 123400, tzinfo=pytz.utc)))
Beispiel #7
0
 def test_format_naive(self):
     t = xso.Time()
     self.assertEqual("19:40:10", t.format(time(19, 40, 10)))
Beispiel #8
0
 def test_parse_milliseconds_timezoned(self):
     t = xso.Time()
     self.assertEqual(time(19, 40, 10, 123456, tzinfo=pytz.utc),
                      t.parse("20:40:10.123456+01:00"))
Beispiel #9
0
 def test_format_timezoned(self):
     t = xso.Time()
     self.assertEqual("19:40:10Z",
                      t.format(time(19, 40, 10, tzinfo=pytz.utc)))
Beispiel #10
0
 def test_parse_milliseconds(self):
     t = xso.Time()
     self.assertEqual(time(20, 40, 10, 123456), t.parse("20:40:10.123456"))
Beispiel #11
0
 def test_parse_local(self):
     t = xso.Time()
     self.assertEqual(time(20, 40, 10), t.parse("20:40:10"))
Beispiel #12
0
 def test_parse_timezoned(self):
     t = xso.Time()
     self.assertEqual(time(19, 40, 10, tzinfo=pytz.utc),
                      t.parse("20:40:10+01:00"))
Beispiel #13
0
 def test_parse_example(self):
     t = xso.Time()
     self.assertEqual(time(19, 40, 10, tzinfo=pytz.utc),
                      t.parse("19:40:10Z"))
Beispiel #14
0
 def test_is_abstract_type(self):
     self.assertIsInstance(xso.Time(), xso.AbstractType)