test_crypto_builtin_md4.py 文件源码

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

项目:GAMADV-XTD 作者: taers232c 项目源码 文件源码
def setUp(self):
        super(MD4_Builtin_Test, self).setUp()

        if has_native_md4():

            # Temporarily make lookup_hash() use builtin pure-python implementation,
            # by monkeypatching hashlib.new() to ensure we fall back to passlib's md4 class.
            orig = hashlib.new
            def wrapper(name, *args):
                if name == "md4":
                    raise ValueError("md4 disabled for testing")
                return orig(name, *args)
            self.patchAttr(hashlib, "new", wrapper)

            # flush cache before & after test, since we're mucking with it.
            lookup_hash.clear_cache()
            self.addCleanup(lookup_hash.clear_cache)

        # make sure we're using right constructor.
        self.assertEqual(self.get_md4_const().__module__, "passlib.crypto._md4")


#=============================================================================
# eof
#=============================================================================
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号