Ticket #8713: test-client.diff

File test-client.diff, 1.4 KB (added by Piotr Lewandowski <django@…>, 16 years ago)
  • django/test/client.py

     
    77    from StringIO import StringIO
    88
    99from django.conf import settings
    10 from django.contrib.auth import authenticate, login
    1110from django.core.handlers.base import BaseHandler
    1211from django.core.handlers.wsgi import WSGIRequest
    1312from django.core.signals import got_request_exception
     
    289288        Sets the Client to appear as if it has successfully logged into a site.
    290289
    291290        Returns True if login is possible; False if the provided credentials
    292         are incorrect, or the user is inactive, or if the sessions framework is
    293         not available.
     291        are incorrect, or the user is inactive, or if the sessions or auth
     292        framework is not available.
    294293        """
     294        if 'django.contrib.auth' not in settings.INSTALLED_APPS \
     295        or 'django.contrib.sessions' not in settings.INSTALLED_APPS:
     296            return False
     297        from django.contrib.auth import authenticate, login
    295298        user = authenticate(**credentials)
    296         if user and user.is_active \
    297                 and 'django.contrib.sessions' in settings.INSTALLED_APPS:
     299        if user and user.is_active:
    298300            engine = __import__(settings.SESSION_ENGINE, {}, {}, [''])
    299301
    300302            # Create a fake request to store login details.
Back to Top