pprint(obj, big_blobs=True, with_decode_path=True)
self.assertFalse(obj.expled)
obj_encoded = obj.encode()
+ self.additional_symmetric_check(value, obj_encoded)
obj_expled = obj(value, expl=tag_expl)
self.assertTrue(obj_expled.expled)
repr(obj_expled)
min_datetime = datetime(1900, 1, 1)
max_datetime = datetime(9999, 12, 31)
+ def additional_symmetric_check(self, value, obj_encoded):
+ if value.microsecond > 0:
+ self.assertFalse(obj_encoded.endswith(b"0Z"))
+
+ def test_x690_vector_valid(self):
+ for data in ((
+ b"19920521000000Z",
+ b"19920622123421Z",
+ b"19920722132100.3Z",
+ )):
+ GeneralizedTime(data)
+
+ def test_x690_vector_invalid(self):
+ for data in ((
+ b"19920520240000Z",
+ b"19920622123421.0Z",
+ b"19920722132100.30Z",
+ )):
+ with self.assertRaises(DecodeError) as err:
+ GeneralizedTime(data)
+ repr(err.exception)
+
def test_go_vectors_invalid(self):
for data in ((
b"20100102030405",
junk
)
+ def test_ns_fractions(self):
+ GeneralizedTime(b"20010101000000.000001Z")
+ with assertRaisesRegex(self, DecodeError, "only microsecond fractions"):
+ GeneralizedTime(b"20010101000000.0000001Z")
+
class TestUTCTime(TimeMixin, CommonMixin, TestCase):
base_klass = UTCTime
min_datetime = datetime(2000, 1, 1)
max_datetime = datetime(2049, 12, 31)
+ def additional_symmetric_check(self, value, obj_encoded):
+ pass
+
+ def test_x690_vector_valid(self):
+ for data in ((
+ b"920521000000Z",
+ b"920622123421Z",
+ b"920722132100Z",
+ )):
+ UTCTime(data)
+
+ def test_x690_vector_invalid(self):
+ for data in ((
+ b"920520240000Z",
+ b"9207221321Z",
+ )):
+ with self.assertRaises(DecodeError) as err:
+ UTCTime(data)
+ repr(err.exception)
+
def test_go_vectors_invalid(self):
for data in ((
b"a10506234540Z",