def assert_patched(self, context=None): mod = sys.modules.get('passlib.ext.django.models') self.assertTrue(mod and mod.adapter.patched, 'patch should have been enabled') for obj, attr, source, patched in self._iter_patch_candidates(): if patched: self.assertTrue(source == 'passlib.ext.django.utils', 'obj=%r attr=%r should have been patched: %r' % ( obj, attr, source)) else: self.assertFalse(source.startswith('passlib.'), 'obj=%r attr=%r should not have been patched: %r' % ( obj, attr, source)) if context is not None: context = CryptContext._norm_source(context) self.assertEqual(mod.password_context.to_dict(resolve=True), context.to_dict(resolve=True)) return
def context(self): return CryptContext._norm_source(self.config)