Ticket #8713: test-client.diff
File test-client.diff, 1.4 KB (added by , 16 years ago) |
---|
-
django/test/client.py
7 7 from StringIO import StringIO 8 8 9 9 from django.conf import settings 10 from django.contrib.auth import authenticate, login11 10 from django.core.handlers.base import BaseHandler 12 11 from django.core.handlers.wsgi import WSGIRequest 13 12 from django.core.signals import got_request_exception … … 289 288 Sets the Client to appear as if it has successfully logged into a site. 290 289 291 290 Returns True if login is possible; False if the provided credentials 292 are incorrect, or the user is inactive, or if the sessions framework is293 not available.291 are incorrect, or the user is inactive, or if the sessions or auth 292 framework is not available. 294 293 """ 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 295 298 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: 298 300 engine = __import__(settings.SESSION_ENGINE, {}, {}, ['']) 299 301 300 302 # Create a fake request to store login details.