mirror of https://github.com/django/django.git
[1.5.x] Improved tests introduced in 04b00b6
.
These tests are expected to fail for the file session backend because it
doesn't handle expiry properly. They didn't because of an error in the
test setup sequence.
Refs #19200, #18194.
Backport of 882c47c
from master.
This commit is contained in:
parent
845d8408e7
commit
e6b0ee768c
|
@ -277,9 +277,11 @@ class SessionTestsMixin(object):
|
||||||
try:
|
try:
|
||||||
self.session['foo'] = 'bar'
|
self.session['foo'] = 'bar'
|
||||||
self.session.set_expiry(-timedelta(seconds=10))
|
self.session.set_expiry(-timedelta(seconds=10))
|
||||||
self.session.create()
|
self.session.save()
|
||||||
|
old_session_key = self.session.session_key
|
||||||
# With an expiry date in the past, the session expires instantly.
|
# With an expiry date in the past, the session expires instantly.
|
||||||
new_session = self.backend(self.session.session_key)
|
new_session = self.backend(self.session.session_key)
|
||||||
|
new_session_key = new_session.session_key
|
||||||
self.assertNotIn('foo', new_session)
|
self.assertNotIn('foo', new_session)
|
||||||
finally:
|
finally:
|
||||||
self.session.delete(old_session_key)
|
self.session.delete(old_session_key)
|
||||||
|
@ -353,15 +355,15 @@ class FileSessionTests(SessionTestsMixin, unittest.TestCase):
|
||||||
backend = FileSession
|
backend = FileSession
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(FileSessionTests, self).setUp()
|
|
||||||
# Do file session tests in an isolated directory, and kill it after we're done.
|
# Do file session tests in an isolated directory, and kill it after we're done.
|
||||||
self.original_session_file_path = settings.SESSION_FILE_PATH
|
self.original_session_file_path = settings.SESSION_FILE_PATH
|
||||||
self.temp_session_store = settings.SESSION_FILE_PATH = tempfile.mkdtemp()
|
self.temp_session_store = settings.SESSION_FILE_PATH = tempfile.mkdtemp()
|
||||||
|
super(FileSessionTests, self).setUp()
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
|
super(FileSessionTests, self).tearDown()
|
||||||
settings.SESSION_FILE_PATH = self.original_session_file_path
|
settings.SESSION_FILE_PATH = self.original_session_file_path
|
||||||
shutil.rmtree(self.temp_session_store)
|
shutil.rmtree(self.temp_session_store)
|
||||||
super(FileSessionTests, self).tearDown()
|
|
||||||
|
|
||||||
@override_settings(
|
@override_settings(
|
||||||
SESSION_FILE_PATH="/if/this/directory/exists/you/have/a/weird/computer")
|
SESSION_FILE_PATH="/if/this/directory/exists/you/have/a/weird/computer")
|
||||||
|
|
Loading…
Reference in New Issue