File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -707,12 +707,16 @@ def test_uuid8(self):
707707 equal (u .int & 0x3fffffffffffffff , lo )
708708
709709 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 )
710+ # Test that UUIDv8-generated values are unique (up to a negligible
711+ # probability of failure). There are 122 bits of entropy and assuming
712+ # that the underlying mt-19937-based random generator is sufficiently
713+ # good, it is unlikely to have a collision of two UUIDs.
714+ N = 1000
715+ 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 })
716720
717721 @support .requires_fork ()
718722 def testIssue8621 (self ):
You can’t perform that action at this time.
0 commit comments