Skip to content

Commit

Permalink
Reverted r16386 because it replaced a brittle method with another not…
Browse files Browse the repository at this point in the history
… less

arbitrary method when the test client checks for the presence of the bundled
session backends+session middleware combination.

We will revisit the issue soon, probably to make these checks even less strict.

Refs #7836, #16605

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17739 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
ramiro committed Mar 15, 2012
1 parent eee65ac commit 3535ddc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
4 changes: 2 additions & 2 deletions django/test/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ def _session(self):
"""
Obtains the current session variables.
"""
if 'django.contrib.sessions.middleware.SessionMiddleware' in settings.MIDDLEWARE_CLASSES:
if 'django.contrib.sessions' in settings.INSTALLED_APPS:
engine = import_module(settings.SESSION_ENGINE)
cookie = self.cookies.get(settings.SESSION_COOKIE_NAME, None)
if cookie:
Expand Down Expand Up @@ -498,7 +498,7 @@ def login(self, **credentials):
"""
user = authenticate(**credentials)
if user and user.is_active \
and 'django.contrib.sessions.middleware.SessionMiddleware' in settings.MIDDLEWARE_CLASSES:
and 'django.contrib.sessions' in settings.INSTALLED_APPS:
engine = import_module(settings.SESSION_ENGINE)

# Create a fake request to store login details.
Expand Down
14 changes: 1 addition & 13 deletions tests/regressiontests/test_client_regress/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import django.template.context
from django.test import Client, TestCase
from django.test.client import encode_file, RequestFactory
from django.test.utils import ContextList, override_settings
from django.test.utils import ContextList
from django.template.response import SimpleTemplateResponse
from django.http import HttpResponse

Expand Down Expand Up @@ -564,18 +564,6 @@ def test_login(self):
self.assertEqual(response.context['user'].username, 'testclient')


class NoSessionsAppInstalled(SessionEngineTests):
"""#7836 - Test client can exercise sessions even when 'django.contrib.sessions' isn't installed."""

# Remove the 'session' contrib app from INSTALLED_APPS
@override_settings(INSTALLED_APPS=tuple(filter(lambda a: a!='django.contrib.sessions', settings.INSTALLED_APPS)))
def test_session(self):
# This request sets a session variable.
response = self.client.get('/test_client_regress/set_session/')
self.assertEqual(response.status_code, 200)
self.assertEqual(self.client.session['session_var'], 'YES')


class URLEscapingTests(TestCase):
def test_simple_argument_get(self):
"Get a view that has a simple string argument"
Expand Down

0 comments on commit 3535ddc

Please sign in to comment.