]> Cypherpunks.ru repositories - pyderasn.git/blobdiff - tests/test_pyderasn.py
Explicitly forbid aware-datetimes usage
[pyderasn.git] / tests / test_pyderasn.py
index 8225fc02eaef4be07fc42093a3f28e4cbc88b933..90d50e9597a0cab8f7f101b9fa5f93abd3ae647a 100644 (file)
@@ -33,6 +33,7 @@ from time import mktime
 from time import time
 from unittest import TestCase
 
+from dateutil.tz import UTC
 from hypothesis import assume
 from hypothesis import given
 from hypothesis import settings
@@ -4727,6 +4728,10 @@ class TestGeneralizedTime(TimeMixin, CommonMixin, TestCase):
             with self.assertRaises(DecodeError):
                 GeneralizedTime(data)
 
+    def test_aware(self):
+        with assertRaisesRegex(self, ValueError, "only naive"):
+            GeneralizedTime(datetime(2000, 1, 1, 1, tzinfo=UTC))
+
 
 class TestUTCTime(TimeMixin, CommonMixin, TestCase):
     base_klass = UTCTime
@@ -5060,6 +5065,10 @@ class TestUTCTime(TimeMixin, CommonMixin, TestCase):
                 junk
             )
 
+    def test_aware(self):
+        with assertRaisesRegex(self, ValueError, "only naive"):
+            UTCTime(datetime(2000, 1, 1, 1, tzinfo=UTC))
+
 
 @composite
 def tlv_value_strategy(draw):