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) ui = uuid4() self.assertEqual(ui, decode(encode(ui))) ui = uuid() self.assertEqual(ui, encode(decode(ui))) 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_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")
def test_generation(self): self.assertTrue(20 < len(uuid()) < 24) self.assertTrue(20 < len(uuid("http://www.example.com/")) < 24) self.assertTrue(20 < len(uuid("HTTP://www.example.com/")) < 24) self.assertTrue(20 < len(uuid("example.com/")) < 24)
def foo3(): print(uuid())