Skip to content

Commit aee2898

Browse files
committed
improve UUIDv7 tests readability
1 parent f7f536e commit aee2898

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Lib/test/test_uuid.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ def test_uuid7(self):
704704
random_bits = counter << 32 | tail
705705

706706
# set all remaining MSB of fake random bits to 1 to ensure that
707-
# the implementation correctly remove them
707+
# the implementation correctly removes them
708708
random_bits = (((1 << 7) - 1) << 73) | random_bits
709709
random_data = random_bits.to_bytes(10)
710710

@@ -754,7 +754,7 @@ def test_uuid7_monotonicity(self):
754754
with mock.patch.multiple(
755755
self.uuid,
756756
_last_timestamp_v7=0,
757-
_last_counter_v7=0
757+
_last_counter_v7=0,
758758
):
759759
# 1 Jan 2023 12:34:56.123_456_789
760760
timestamp_ns = 1672533296_123_456_789 # ns precision
@@ -764,6 +764,7 @@ def test_uuid7_monotonicity(self):
764764
counter_hi = random.getrandbits(11)
765765
counter_lo = random.getrandbits(29)
766766
counter = (counter_hi << 30) | counter_lo
767+
self.assertLess(counter + 1, 0x3ff_ffff_ffff)
767768

768769
tail = random.getrandbits(32)
769770
random_bits = counter << 32 | tail
@@ -816,6 +817,7 @@ def test_uuid7_timestamp_backwards(self):
816817
counter_hi = random.getrandbits(11)
817818
counter_lo = random.getrandbits(29)
818819
counter = (counter_hi << 30) | counter_lo
820+
self.assertLess(counter + 1, 0x3ff_ffff_ffff)
819821

820822
tail_bytes = os.urandom(4)
821823
tail = int.from_bytes(tail_bytes)
@@ -854,7 +856,7 @@ def test_uuid7_overflow_counter(self):
854856
new_counter = (new_counter_hi << 30) | new_counter_lo
855857

856858
tail = random.getrandbits(32)
857-
random_bits = new_counter << 32 | tail
859+
random_bits = (new_counter << 32) | tail
858860
random_data = random_bits.to_bytes(10)
859861

860862
with (

0 commit comments

Comments
 (0)