8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1c9b020 commit 4c14f03Copy full SHA for 4c14f03
Lib/test/test_uuid.py
@@ -707,12 +707,16 @@ def test_uuid8(self):
707
equal(u.int & 0x3fffffffffffffff, lo)
708
709
def test_uuid8_uniqueness(self):
710
- # Test that UUIDv8-generated values are unique
711
- # (up to a negligible probability of failure).
712
- u1 = self.uuid.uuid8()
713
- u2 = self.uuid.uuid8()
714
- self.assertNotEqual(u1.int, u2.int)
715
- self.assertEqual(u1.version, u2.version)
+ # Test that UUIDv8-generated values are unique (up to a negligible
+ # probability of failure). There are 122 bits of entropy and assuming
+ # that the underlying mt-19937-based random generator is sufficiently
+ # good, it is unlikely to have a collision of two UUIDs.
+ N = 1000
+ uuids = {self.uuid.uuid8() for _ in range(N)}
716
+ self.assertEqual(len(uuids), N)
717
+
718
+ versions = {u.version for u in uuids}
719
+ self.assertSetEqual(versions, {8})
720
721
@support.requires_fork()
722
def testIssue8621(self):