]> Cypherpunks repositories - keks.git/commitdiff
Move Leapsec-related tests outside common ones
authorSergey Matveev <stargrave@stargrave.org>
Sat, 30 Nov 2024 18:42:29 +0000 (21:42 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Sat, 30 Nov 2024 19:38:56 +0000 (22:38 +0300)
Because they are not directly involved in TAI-testing, but the
correctness of our database.

pyac/tests/test_tai.py

index 04bf3d6e90aa95419b0936cd36d486a2bbb7eae273534b81b9796c4ec7af1a05..e0b4fcb0c2bb937db17f9b6d3107f5f4ec7291b11aa39800f1b65d555c028ff0 100644 (file)
@@ -17,6 +17,7 @@ TagTAI64 = 0x18
 TagTAI64N = 0x19
 TagTAI64NA = 0x1A
 
+# This is output of: curl http://cr.yp.to/libtai/leapsecs.dat | xxd -c 8 -p
 DJB_Leapsecs = (
     "4000000004b2580a",
     "4000000005a4ec0b",
@@ -123,22 +124,26 @@ class TestTAI64(TestCase):
             )
         self.assertEqual(str(err.exception), "too many attoseconds")
 
-    def test_leapseconds_match_DJB(self) -> None:
-        """Check that our pyac.Leapsecs is equally calculated to DJB's
-        ``curl http://cr.yp.to/libtai/leapsecs.dat | xxd -c 8 -p``
+
+class TestLeapsecs(TestCase):
+    def test_match_DJB(self) -> None:
+        """Check that our pyac.Leapsecs is equally calculated to DJB's one
         """
-        for our, their in zip(
-            Leapsecs,
-            DJB_Leapsecs
-        ):
+        for our, their in zip(Leapsecs, DJB_Leapsecs):
             self.assertEqual(
                 our,
                 int.from_bytes(bytes.fromhex(their), "big") - TAI64Base,
             )
 
-    def test_decode_leapsecond(self) -> None:
+    def test_decode(self) -> None:
         for leapsec in DJB_Leapsecs:
-            decoded, tail = loads(v=b"\x18" + bytes.fromhex(leapsec), leapsecUTCAllow=True)
+            decoded, tail = loads(
+                v=b"\x18" + bytes.fromhex(leapsec),
+                leapsecUTCAllow=True,
+            )
             self.assertIsInstance(decoded, datetime)
-            decoded, tail = loads(v=b"\x18" + bytes.fromhex(leapsec), leapsecUTCAllow=False)
+            decoded, tail = loads(
+                v=b"\x18" + bytes.fromhex(leapsec),
+                leapsecUTCAllow=False,
+            )
             self.assertIsInstance(decoded, Raw)