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

Method test_uuid8

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

Source from the content-addressed store, hash-verified

1083 equal(u.int & 0xffff_ffff, tail)
1084
1085 def test_uuid8(self):
1086 equal = self.assertEqual
1087 u = self.uuid.uuid8()
1088
1089 equal(u.variant, self.uuid.RFC_4122)
1090 equal(u.version, 8)
1091
1092 for (_, hi, mid, lo) in product(
1093 range(10), # repeat 10 times
1094 [None, 0, random.getrandbits(48)],
1095 [None, 0, random.getrandbits(12)],
1096 [None, 0, random.getrandbits(62)],
1097 ):
1098 u = self.uuid.uuid8(hi, mid, lo)
1099 equal(u.variant, self.uuid.RFC_4122)
1100 equal(u.version, 8)
1101 if hi is not None:
1102 equal((u.int >> 80) & 0xffffffffffff, hi)
1103 if mid is not None:
1104 equal((u.int >> 64) & 0xfff, mid)
1105 if lo is not None:
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

Callers

nothing calls this directly

Calls 1

getrandbitsMethod · 0.45

Tested by

no test coverage detected