From: Sergey Matveev Date: Sat, 30 Nov 2024 18:42:29 +0000 (+0300) Subject: Move Leapsec-related tests outside common ones X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=afd33c4ee617af147b40372921a88604ece459597682e648388e756dee7590a8;p=keks.git Move Leapsec-related tests outside common ones Because they are not directly involved in TAI-testing, but the correctness of our database. --- diff --git a/pyac/tests/test_tai.py b/pyac/tests/test_tai.py index 04bf3d6..e0b4fcb 100644 --- a/pyac/tests/test_tai.py +++ b/pyac/tests/test_tai.py @@ -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)