Commit 548a06fb authored by Jérome Perrin's avatar Jérome Perrin

use pprint for easier display of existing local roles


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@34065 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 55592212
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
"""Base Class for security tests using ERP5Security and DCWorkflow """Base Class for security tests using ERP5Security and DCWorkflow
""" """
from pprint import pformat
import transaction import transaction
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.SecurityManagement import getSecurityManager from AccessControl.SecurityManagement import getSecurityManager
...@@ -71,14 +72,14 @@ class AssertPermissionMethod(object): ...@@ -71,14 +72,14 @@ class AssertPermissionMethod(object):
groups = user.getGroups() groups = user.getGroups()
self._instance.fail( self._instance.fail(
'User %s does NOT have %s permission on %s %s (user roles: [%s], ' 'User %s does NOT have %s permission on %s %s (user roles: [%s], '
'roles needed: [%s], existing local roles: %s, ' 'roles needed: [%s], existing local roles:\n%s\n'
'your user groups: [%s])' % 'your user groups: [%s])' %
(username, self._permission_name, document.getPortalTypeName(), (username, self._permission_name, document.getPortalTypeName(),
document, ', '.join(user.getRolesInContext(document)), document, ', '.join(user.getRolesInContext(document)),
', '.join([x['name'] for x in ', '.join([x['name'] for x in
document.rolesOfPermission(self._permission_name) document.rolesOfPermission(self._permission_name)
if x['selected']]), if x['selected']]),
repr(document.get_local_roles()), pformat(document.get_local_roles()),
', '.join(groups))) ', '.join(groups)))
finally: finally:
setSecurityManager(sm) setSecurityManager(sm)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment