Skip to content

Commit

Permalink
improve UUIDv7 uniqueness tests
Browse files Browse the repository at this point in the history
  • Loading branch information
picnixz committed Dec 19, 2024
1 parent aee2898 commit 1a5ac19
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Lib/test/test_uuid.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,9 +741,13 @@ def test_uuid7_uniqueness(self):
# uses os.urandom() as a PRNG which features better randomness.
#
# Until reaching UNIX_EPOCH + 10'000 years, the probability for
# generating two identical UUIDs is negligilbe.
uuids = {self.uuid.uuid7() for _ in range(1000)}
self.assertEqual(len(uuids), 1000)
# generating two identical UUIDs is negligible.
N = 1000
uuids = {self.uuid.uuid7() for _ in range(N)}
self.assertEqual(len(uuids), N)

versions = {u.version for u in uuids}
self.assertSetEqual(versions, {7})

def test_uuid7_monotonicity(self):
equal = self.assertEqual
Expand Down

0 comments on commit 1a5ac19

Please sign in to comment.