'Unit/integration testing helper: Registers a pair of faux
:app:`Pyramid` security policies: a :term:`authentication
policy` and a :term:`authorization policy`.
The behavior of the registered :term:`authorization policy`
depends on the ``permissive`` argument.  If ``permissive`` is
true, a permissive :term:`authorization policy` is registered;
this policy allows all access.  If ``permissive`` is false, a
nonpermissive :term:`authorization policy` is registered; this
policy denies all access.
``remember_result``, if provided, should be the result returned by
the ``remember`` method of the faux authentication policy.  If it is
not provided (or it is provided, and is ``None``), the default value
``[]`` (the empty list) will be returned by ``remember``.
``forget_result``, if provided, should be the result returned by
the ``forget`` method of the faux authentication policy.  If it is
not provided (or it is provided, and is ``None``), the default value
``[]`` (the empty list) will be returned by ``forget``.
The behavior of the registered :term:`authentication policy`
depends on the values provided for the ``userid`` and
``groupids`` argument.  The authentication policy will return
the userid identifier implied by the ``userid`` argument and
the group ids implied by the ``groupids`` argument when the
:attr:`pyramid.request.Request.authenticated_userid` or
:attr:`pyramid.request.Request.effective_principals` APIs are
used.
This function is most useful when testing code that uses
the APIs named :meth:`pyramid.request.Request.has_permission`,
:attr:`pyramid.request.Request.authenticated_userid`,
:attr:`pyramid.request.Request.effective_principals`, and
:func:`pyramid.security.principals_allowed_by_permission`.
.. versionadded:: 1.4
The ``remember_result`` argument.
.. versionadded:: 1.4
The ``forget_result`` argument.'

def testing_securitypolicy(self, userid=None, groupids=(), permissive=True, remember_result=None, forget_result=None):

    from pyramid.testing import DummySecurityPolicy
    policy = DummySecurityPolicy(userid, groupids, permissive, remember_result, forget_result)
    self.registry.registerUtility(policy, IAuthorizationPolicy)
    self.registry.registerUtility(policy, IAuthenticationPolicy)
    return policy
