本文整理汇总了Python中passlib.context.CryptPolicy.from_source方法的典型用法代码示例。如果您正苦于以下问题:Python CryptPolicy.from_source方法的具体用法?Python CryptPolicy.from_source怎么用?Python CryptPolicy.from_source使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类passlib.context.CryptPolicy
的用法示例。
在下文中一共展示了CryptPolicy.from_source方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_03_from_source
# 需要导入模块: from passlib.context import CryptPolicy [as 别名]
# 或者: from passlib.context.CryptPolicy import from_source [as 别名]
def test_03_from_source(self):
"test CryptPolicy.from_source() constructor"
#pass it a path
policy = CryptPolicy.from_source(self.sample_config_1s_path)
self.assertEqual(policy.to_dict(), self.sample_config_1pd)
#pass it a string
policy = CryptPolicy.from_source(self.sample_config_1s)
self.assertEqual(policy.to_dict(), self.sample_config_1pd)
#pass it a dict (NOTE: make a copy to detect in-place modifications)
policy = CryptPolicy.from_source(self.sample_config_1pd.copy())
self.assertEqual(policy.to_dict(), self.sample_config_1pd)
#pass it existing policy
p2 = CryptPolicy.from_source(policy)
self.assertIs(policy, p2)
#pass it something wrong
self.assertRaises(TypeError, CryptPolicy.from_source, 1)
self.assertRaises(TypeError, CryptPolicy.from_source, [])