def assert_valid_password(self, user, hash=UNSET, saved=None):
"""check that user object has a usuable password hash.
:param hash: optionally check it has this exact hash
:param saved: check that mock commit history
for user.password matches this list
"""
if hash is UNSET:
self.assertNotEqual(user.password, "!")
self.assertNotEqual(user.password, None)
else:
self.assertEqual(user.password, hash)
if has_django1 or self.patched:
self.assertTrue(user.has_usable_password())
self.assertEqual(user.pop_saved_passwords(),
[] if saved is None else [saved])
评论列表
文章目录