Ticket #15929: django-patch-15929.diff

File django-patch-15929.diff, 760 bytes (added by Michael, 13 years ago)
  • django/test/client.py

    diff --git a/django/test/client.py b/django/test/client.py
    index 5cbc0ca..e780ff6 100644
    a b class RequestFactory(object):  
    205205
    206206    def request(self, **request):
    207207        "Construct a generic request object."
    208         return WSGIRequest(self._base_environ(**request))
     208        req = WSGIRequest(self._base_environ(**request))
     209
     210        # The contrib.auth.middleware.AuthenticationMiddleware patches the
     211        # WSGIRequest instance to add the LazyUser() object. For testing
     212        # purposes we need to remove it.
     213        if hasattr(req, 'user'):
     214            delattr(req, 'user')
     215        return req
    209216
    210217    def _get_path(self, parsed):
    211218        # If there are parameters, add them
Back to Top