예제 #1
0
 def test_coerce_accepts_date(self):
     t = xso.Date()
     v = datetime.utcnow().date()
     self.assertEqual(t.coerce(v), v)
예제 #2
0
 def test_coerce_rejects_time(self):
     t = xso.Date()
     with self.assertRaisesRegex(TypeError, "must be a date object"):
         t.coerce(datetime.utcnow().time())
예제 #3
0
 def test_parse(self):
     t = xso.Date()
     self.assertEqual(
         t.parse("1776-07-04"),
         date(1776, 7, 4),
     )
예제 #4
0
 def test_format(self):
     t = xso.Date()
     self.assertEqual(
         t.format(date(1776, 7, 4)),
         "1776-07-04",
     )
예제 #5
0
 def test_is_abstract_type(self):
     self.assertIsInstance(xso.Date(), xso.AbstractType)