test_timeuuid.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:komlogd 作者: komlog-io 项目源码 文件源码
def test_create_timeuuid_with_uuid4_string_should_fail(self):
        ''' creating a TimeUUID with a hex uuid4 should fail'''
        for i in range(1,100):
            u = uuid.uuid4()
            with self.assertRaises(ValueError) as cm:
                t = timeuuid.TimeUUID(s=u.hex)
            self.assertEqual(str(cm.exception), 'Invalid UUID type')
        for fn in [uuid.uuid3, uuid.uuid5]:
            for i in range(1,100):
                u = fn(uuid.NAMESPACE_DNS,str(os.urandom(10)))
                with self.assertRaises(ValueError) as cm:
                    t = timeuuid.TimeUUID(s=u.hex)
                self.assertEqual(str(cm.exception), 'Invalid UUID type')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号