Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_alphabet(self):
backup_alphabet = get_alphabet()
alphabet = "01"
set_alphabet(alphabet)
self.assertEqual(alphabet, get_alphabet())
set_alphabet("01010101010101")
self.assertEqual(alphabet, get_alphabet())
self.assertEqual(set(uuid()), set("01"))
self.assertTrue(116 < len(uuid()) < 140)
u = uuid4()
self.assertEqual(u, decode(encode(u)))
u = uuid()
self.assertEqual(u, encode(decode(u)))
self.assertRaises(ValueError, set_alphabet, "1")
self.assertRaises(ValueError, set_alphabet, "1111111")
set_alphabet(backup_alphabet)
self.assertRaises(ValueError, lambda x: ShortUUID(x), "0")
alphabet = "01"
set_alphabet(alphabet)
self.assertEqual(alphabet, get_alphabet())
set_alphabet("01010101010101")
self.assertEqual(alphabet, get_alphabet())
self.assertEqual(set(uuid()), set("01"))
self.assertTrue(116 < len(uuid()) < 140)
u = uuid4()
self.assertEqual(u, decode(encode(u)))
u = uuid()
self.assertEqual(u, encode(decode(u)))
self.assertRaises(ValueError, set_alphabet, "1")
self.assertRaises(ValueError, set_alphabet, "1111111")
set_alphabet(backup_alphabet)
self.assertRaises(ValueError, lambda x: ShortUUID(x), "0")
def test_encoding(self):
u = UUID("{3b1f8b40-222c-4a6e-b77e-779d5a94e21c}")
self.assertEqual(encode(u), "CXc85b4rqinB7s5J52TRYb")