MCPcopy Index your code
hub / github.com/python/cpython / test_uuid8_uniqueness

Method test_uuid8_uniqueness

Lib/test/test_uuid.py:1108–1118  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1106 equal(u.int & 0x3fffffffffffffff, lo)
1107
1108 def test_uuid8_uniqueness(self):
1109 # Test that UUIDv8-generated values are unique (up to a negligible
1110 # probability of failure). There are 122 bits of entropy and assuming
1111 # that the underlying mt-19937-based random generator is sufficiently
1112 # good, it is unlikely to have a collision of two UUIDs.
1113 N = 1000
1114 uuids = {self.uuid.uuid8() for _ in range(N)}
1115 self.assertEqual(len(uuids), N)
1116
1117 versions = {u.version for u in uuids}
1118 self.assertSetEqual(versions, {8})
1119
1120 @warnings_helper.ignore_fork_in_thread_deprecation_warnings()
1121 @support.requires_fork()

Callers

nothing calls this directly

Calls 2

assertSetEqualMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected