MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_uuid6_node

Method test_uuid6_node

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

Source from the content-addressed store, hash-verified

790 self.assertLess(len(uuids), N, 'collision property does not hold')
791
792 def test_uuid6_node(self):
793 # Make sure the given node ID appears in the UUID.
794 #
795 # Note: when no node ID is specified, the same logic as for UUIDv1
796 # is applied to UUIDv6. In particular, there is no need to test that
797 # getnode() correctly returns positive integers of exactly 48 bits
798 # since this is done in test_uuid1_eui64().
799 self.assertLessEqual(self.uuid.uuid6().node.bit_length(), 48)
800
801 self.assertEqual(self.uuid.uuid6(0).node, 0)
802
803 # tests with explicit values
804 max_node = 0xffff_ffff_ffff
805 self.assertEqual(self.uuid.uuid6(max_node).node, max_node)
806 big_node = 0xE_1234_5678_ABCD # 52-bit node
807 res_node = 0x0_1234_5678_ABCD # truncated to 48 bits
808 self.assertEqual(self.uuid.uuid6(big_node).node, res_node)
809
810 # randomized tests
811 for _ in range(10):
812 # node with > 48 bits is truncated
813 for b in [24, 48, 72]:
814 node = (1 << (b - 1)) | random.getrandbits(b)
815 with self.subTest(node=node, bitlen=b):
816 self.assertEqual(node.bit_length(), b)
817 u = self.uuid.uuid6(node=node)
818 self.assertEqual(u.node, node & 0xffff_ffff_ffff)
819
820 def test_uuid6_clock_seq(self):
821 # Make sure the supplied clock sequence appears in the UUID.

Callers

nothing calls this directly

Calls 5

assertLessEqualMethod · 0.80
subTestMethod · 0.80
bit_lengthMethod · 0.45
assertEqualMethod · 0.45
getrandbitsMethod · 0.45

Tested by

no test coverage detected