Пример #1
0
    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])
Пример #2
0
 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)
Пример #3
0
 def test_hex(self):
     self.assertEqual(
         UUID('a8098c1a-f86e-11da-bd1a-00112444be1e').hex,
         "a8098c1af86e11dabd1a00112444be1e")
Пример #4
0
 def test_str(self):
     self.assertEqual(str(UUID('a8098c1a-f86e-11da-bd1a-00112444be1e')),
                      "a8098c1a-f86e-11da-bd1a-00112444be1e")
Пример #5
0
 def test_int(self):
     self.assertEqual(int(UUID('a8098c1a-f86e-11da-bd1a-00112444be1e')),
                      223359875637754765292326297443183672862)
Пример #6
0
 def test_hash(self):
     self.assertEqual(hash(UUID('a8098c1a-f86e-11da-bd1a-00112444be1e')),
                      2118487228160494877)
Пример #7
0
 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)
Пример #8
0
 def test_version(self):
     self.assertEqual(
         UUID('a8098c1a-f86e-11da-bd1a-00112444be1e').version, 1)
Пример #9
0
 def test_variant_RFC_4122(self):
     self.assertEqual(
         UUID('a8098c1a-f86e-11da-bd1a-00112444be1e').variant, RFC_4122)
Пример #10
0
 def test_from_uuid(self):
     self.assertEqual(UUID(uuid=self._uuid), self._uuid)
Пример #11
0
 def test_int(self):
     _int = 223359875637754765292326297443183672862
     uuid = _UUID(int=_int)
     cyuuid = UUID(int=_int)
     self.assertEqual(uuid, cyuuid)
Пример #12
0
 def test_fields(self):
     fields = (0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x567812345678)
     uuid = _UUID(fields=fields)
     cyuuid = UUID(fields=fields)
     self.assertEqual(uuid, cyuuid)
Пример #13
0
 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)
Пример #14
0
 def test_variant_NSC(self):
     self.assertEqual(
         UUID('a8098c1a-f86e-11da-0d1a-00112444be1e').variant, RESERVED_NCS)
Пример #15
0
 def test_not_equal(self):
     self.assertNotEqual(UUID('b8098c1a-f86e-11da-bd1a-00112444be1e'),
                         self._uuid)
Пример #16
0
 def test_variant_MS(self):
     self.assertEqual(
         UUID('a8098c1a-f86e-11da-dd1a-00112444be1e').variant,
         RESERVED_MICROSOFT)
Пример #17
0
 def test_lte(self):
     self.assertLessEqual(UUID('a8098c1a-f86e-11da-bd1a-00112444be1e'),
                          self._uuid)
     self.assertLessEqual(UUID('a7098c1a-f86e-11da-bd1a-00112444be1e'),
                          self._uuid)
Пример #18
0
 def test_variant_FUTURE(self):
     self.assertEqual(
         UUID('a8098c1a-f86e-11da-ed1a-00112444be1e').variant,
         RESERVED_FUTURE)
Пример #19
0
 def test_gte(self):
     self.assertGreaterEqual(UUID('a8098c1a-f86e-11da-bd1a-00112444be1e'),
                             self._uuid)
     self.assertGreaterEqual(UUID('a9098c1a-f86e-11da-bd1a-00112444be1e'),
                             self._uuid)
Пример #20
0
 def setUp(self):
     self._uuid = _UUID("a8098c1a-f86e-11da-bd1a-00112444be1e")
     self._cyuuid = UUID("a8098c1a-f86e-11da-bd1a-00112444be1e")
Пример #21
0
 def test_hex(self):
     hex = "a8098c1a-f86e-11da-bd1a-00112444be1e"
     uuid = _UUID(hex=hex)
     cyuuid = UUID(hex=hex)
     self.assertEqual(uuid, cyuuid)