Exemple #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())
Exemple #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())
Exemple #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)
Exemple #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)
Exemple #5
0
 def test_format_naive_microseconds(self):
     t = xso.Time()
     self.assertEqual("19:40:10.1234", t.format(time(19, 40, 10, 123400)))
Exemple #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)))
Exemple #7
0
 def test_format_naive(self):
     t = xso.Time()
     self.assertEqual("19:40:10", t.format(time(19, 40, 10)))
Exemple #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"))
Exemple #9
0
 def test_format_timezoned(self):
     t = xso.Time()
     self.assertEqual("19:40:10Z",
                      t.format(time(19, 40, 10, tzinfo=pytz.utc)))
Exemple #10
0
 def test_parse_milliseconds(self):
     t = xso.Time()
     self.assertEqual(time(20, 40, 10, 123456), t.parse("20:40:10.123456"))
Exemple #11
0
 def test_parse_local(self):
     t = xso.Time()
     self.assertEqual(time(20, 40, 10), t.parse("20:40:10"))
Exemple #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"))
Exemple #13
0
 def test_parse_example(self):
     t = xso.Time()
     self.assertEqual(time(19, 40, 10, tzinfo=pytz.utc),
                      t.parse("19:40:10Z"))
Exemple #14
0
 def test_is_abstract_type(self):
     self.assertIsInstance(xso.Time(), xso.AbstractType)