本文整理汇总了Python中passlib.context.CryptPolicy.replace方法的典型用法代码示例。如果您正苦于以下问题:Python CryptPolicy.replace方法的具体用法?Python CryptPolicy.replace怎么用?Python CryptPolicy.replace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类passlib.context.CryptPolicy
的用法示例。
在下文中一共展示了CryptPolicy.replace方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_15_min_verify_time
# 需要导入模块: from passlib.context import CryptPolicy [as 别名]
# 或者: from passlib.context.CryptPolicy import replace [as 别名]
def test_15_min_verify_time(self):
pa = CryptPolicy()
self.assertEqual(pa.get_min_verify_time(), 0)
self.assertEqual(pa.get_min_verify_time('admin'), 0)
pb = pa.replace(min_verify_time=.1)
self.assertEqual(pb.get_min_verify_time(), .1)
self.assertEqual(pb.get_min_verify_time('admin'), .1)
pc = pa.replace(admin__context__min_verify_time=.2)
self.assertEqual(pc.get_min_verify_time(), 0)
self.assertEqual(pc.get_min_verify_time('admin'), .2)
pd = pb.replace(admin__context__min_verify_time=.2)
self.assertEqual(pd.get_min_verify_time(), .1)
self.assertEqual(pd.get_min_verify_time('admin'), .2)
示例2: test_15_min_verify_time
# 需要导入模块: from passlib.context import CryptPolicy [as 别名]
# 或者: from passlib.context.CryptPolicy import replace [as 别名]
def test_15_min_verify_time(self):
"test get_min_verify_time() method"
# silence deprecation warnings for min verify time
warnings.filterwarnings("ignore", category=DeprecationWarning)
pa = CryptPolicy()
self.assertEqual(pa.get_min_verify_time(), 0)
self.assertEqual(pa.get_min_verify_time('admin'), 0)
pb = pa.replace(min_verify_time=.1)
self.assertEqual(pb.get_min_verify_time(), .1)
self.assertEqual(pb.get_min_verify_time('admin'), .1)
pc = pa.replace(admin__context__min_verify_time=.2)
self.assertEqual(pc.get_min_verify_time(), 0)
self.assertEqual(pc.get_min_verify_time('admin'), .2)
pd = pb.replace(admin__context__min_verify_time=.2)
self.assertEqual(pd.get_min_verify_time(), .1)
self.assertEqual(pd.get_min_verify_time('admin'), .2)
示例3: test_05_replace
# 需要导入模块: from passlib.context import CryptPolicy [as 别名]
# 或者: from passlib.context.CryptPolicy import replace [as 别名]
def test_05_replace(self):
"test CryptPolicy.replace() constructor"
p1 = CryptPolicy(**self.sample_config_1pd)
#check overlaying sample 2
p2 = p1.replace(**self.sample_config_2pd)
self.assertEqual(p2.to_dict(), self.sample_config_12pd)
#check repeating overlay makes no change
p2b = p2.replace(**self.sample_config_2pd)
self.assertEqual(p2b.to_dict(), self.sample_config_12pd)
#check overlaying sample 3
p3 = p2.replace(self.sample_config_3pd)
self.assertEqual(p3.to_dict(), self.sample_config_123pd)