def test_multiple_inputs(self): hex = "a8098c1a-f86e-11da-bd1a-00112444be1e" fields = (0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x567812345678) bytes_le = b'\x1a\x8c\t\xa8n\xf8\xda\x11\xbd\x1a\x00\x11$D\xbe\x1e' _bytes = b'\xa8\t\x8c\x1a\xf8n\x11\xda\xbd\x1a\x00\x11$D\xbe\x1e' _int = 223359875637754765292326297443183672862 for x in [ (hex, fields, bytes_le, _bytes, _int), (hex, fields, bytes_le, _bytes, None), (hex, fields, bytes_le, None, None), (hex, fields, None, None, None), (hex, None, None, None, None), (None, fields, bytes_le, _bytes, _int), (hex, None, bytes_le, _bytes, _int), (hex, fields, None, _bytes, _int), (hex, fields, bytes_le, None, _int), (hex, fields, bytes_le, _bytes, None), (None, None, None, _bytes, _int), ]: with self.subTest(params=x): msg = "one of the hex, bytes, bytes_le, fields, or int arguments must be given" with self.assertRaisesRegex(TypeError, msg): UUID(hex=x[0], bytes=[1], bytes_le=x[2], fields=x[3], int=x[4])
def test_version(self): hex = "a8098c1a-f86e-11da-bd1a-00112444be1e" for version in range(1, 5): with self.subTest(version=version): uuid = _UUID(hex=hex, version=version) cyuuid = UUID(hex=hex, version=version) self.assertEqual(uuid, cyuuid)
def test_hex(self): self.assertEqual( UUID('a8098c1a-f86e-11da-bd1a-00112444be1e').hex, "a8098c1af86e11dabd1a00112444be1e")
def test_str(self): self.assertEqual(str(UUID('a8098c1a-f86e-11da-bd1a-00112444be1e')), "a8098c1a-f86e-11da-bd1a-00112444be1e")
def test_int(self): self.assertEqual(int(UUID('a8098c1a-f86e-11da-bd1a-00112444be1e')), 223359875637754765292326297443183672862)
def test_hash(self): self.assertEqual(hash(UUID('a8098c1a-f86e-11da-bd1a-00112444be1e')), 2118487228160494877)
def test_bytes(self): _bytes = b'\xa8\t\x8c\x1a\xf8n\x11\xda\xbd\x1a\x00\x11$D\xbe\x1e' uuid = _UUID(bytes=_bytes) cyuuid = UUID(bytes=_bytes) self.assertEqual(uuid, cyuuid)
def test_version(self): self.assertEqual( UUID('a8098c1a-f86e-11da-bd1a-00112444be1e').version, 1)
def test_variant_RFC_4122(self): self.assertEqual( UUID('a8098c1a-f86e-11da-bd1a-00112444be1e').variant, RFC_4122)
def test_from_uuid(self): self.assertEqual(UUID(uuid=self._uuid), self._uuid)
def test_int(self): _int = 223359875637754765292326297443183672862 uuid = _UUID(int=_int) cyuuid = UUID(int=_int) self.assertEqual(uuid, cyuuid)
def test_fields(self): fields = (0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x567812345678) uuid = _UUID(fields=fields) cyuuid = UUID(fields=fields) self.assertEqual(uuid, cyuuid)
def test_bytes_le(self): bytes_le = b'\x1a\x8c\t\xa8n\xf8\xda\x11\xbd\x1a\x00\x11$D\xbe\x1e' uuid = _UUID(bytes_le=bytes_le) cyuuid = UUID(bytes_le=bytes_le) self.assertEqual(uuid, cyuuid)
def test_variant_NSC(self): self.assertEqual( UUID('a8098c1a-f86e-11da-0d1a-00112444be1e').variant, RESERVED_NCS)
def test_not_equal(self): self.assertNotEqual(UUID('b8098c1a-f86e-11da-bd1a-00112444be1e'), self._uuid)
def test_variant_MS(self): self.assertEqual( UUID('a8098c1a-f86e-11da-dd1a-00112444be1e').variant, RESERVED_MICROSOFT)
def test_lte(self): self.assertLessEqual(UUID('a8098c1a-f86e-11da-bd1a-00112444be1e'), self._uuid) self.assertLessEqual(UUID('a7098c1a-f86e-11da-bd1a-00112444be1e'), self._uuid)
def test_variant_FUTURE(self): self.assertEqual( UUID('a8098c1a-f86e-11da-ed1a-00112444be1e').variant, RESERVED_FUTURE)
def test_gte(self): self.assertGreaterEqual(UUID('a8098c1a-f86e-11da-bd1a-00112444be1e'), self._uuid) self.assertGreaterEqual(UUID('a9098c1a-f86e-11da-bd1a-00112444be1e'), self._uuid)
def setUp(self): self._uuid = _UUID("a8098c1a-f86e-11da-bd1a-00112444be1e") self._cyuuid = UUID("a8098c1a-f86e-11da-bd1a-00112444be1e")
def test_hex(self): hex = "a8098c1a-f86e-11da-bd1a-00112444be1e" uuid = _UUID(hex=hex) cyuuid = UUID(hex=hex) self.assertEqual(uuid, cyuuid)