Refs #24121 -- Added __repr__() to PermWrapper.
This commit is contained in:
parent
214b36f50a
commit
22da686ca9
|
@ -25,6 +25,9 @@ class PermWrapper:
|
||||||
def __init__(self, user):
|
def __init__(self, user):
|
||||||
self.user = user
|
self.user = user
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return f'{self.__class__.__qualname__}({self.user!r})'
|
||||||
|
|
||||||
def __getitem__(self, app_label):
|
def __getitem__(self, app_label):
|
||||||
return PermLookupDict(self.user, app_label)
|
return PermLookupDict(self.user, app_label)
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,9 @@ from .settings import AUTH_MIDDLEWARE, AUTH_TEMPLATES
|
||||||
|
|
||||||
|
|
||||||
class MockUser:
|
class MockUser:
|
||||||
|
def __repr__(self):
|
||||||
|
return 'MockUser()'
|
||||||
|
|
||||||
def has_module_perms(self, perm):
|
def has_module_perms(self, perm):
|
||||||
return perm == 'mockapp'
|
return perm == 'mockapp'
|
||||||
|
|
||||||
|
@ -33,6 +36,10 @@ class PermWrapperTests(SimpleTestCase):
|
||||||
self.eq_calls += 1
|
self.eq_calls += 1
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def test_repr(self):
|
||||||
|
perms = PermWrapper(MockUser())
|
||||||
|
self.assertEqual(repr(perms), 'PermWrapper(MockUser())')
|
||||||
|
|
||||||
def test_permwrapper_in(self):
|
def test_permwrapper_in(self):
|
||||||
"""
|
"""
|
||||||
'something' in PermWrapper works as expected.
|
'something' in PermWrapper works as expected.
|
||||||
|
|
Loading…
Reference in New Issue