diff options
| author | Jon Dufresne <jon.dufresne@gmail.com> | 2019-11-07 01:26:22 -0800 |
|---|---|---|
| committer | Carlton Gibson <carlton.gibson@noumenal.es> | 2019-11-07 10:26:22 +0100 |
| commit | 77aa74cb70dd85497dbade6bc0f394aa41e88c94 (patch) | |
| tree | f526b5e63897415e8753c6e38396bba535e3fc75 /tests/sessions_tests | |
| parent | 367634f976ab43db93321bf4eb898449b670e291 (diff) | |
Refs #29983 -- Added support for using pathlib.Path in all settings.
Diffstat (limited to 'tests/sessions_tests')
| -rw-r--r-- | tests/sessions_tests/tests.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/sessions_tests/tests.py b/tests/sessions_tests/tests.py index 24e4e0c81b..ebdd311816 100644 --- a/tests/sessions_tests/tests.py +++ b/tests/sessions_tests/tests.py @@ -6,6 +6,7 @@ import tempfile import unittest from datetime import timedelta from http import cookies +from pathlib import Path from django.conf import settings from django.contrib.sessions.backends.base import UpdateError @@ -521,7 +522,7 @@ class FileSessionTests(SessionTestsMixin, unittest.TestCase): def setUp(self): # 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.temp_session_store = settings.SESSION_FILE_PATH = tempfile.mkdtemp() + self.temp_session_store = settings.SESSION_FILE_PATH = self.mkdtemp() # Reset the file session backend's internal caches if hasattr(self.backend, '_storage_path'): del self.backend._storage_path @@ -532,6 +533,9 @@ class FileSessionTests(SessionTestsMixin, unittest.TestCase): settings.SESSION_FILE_PATH = self.original_session_file_path shutil.rmtree(self.temp_session_store) + def mkdtemp(self): + return tempfile.mkdtemp() + @override_settings( SESSION_FILE_PATH='/if/this/directory/exists/you/have/a/weird/computer', ) @@ -598,6 +602,12 @@ class FileSessionTests(SessionTestsMixin, unittest.TestCase): self.assertEqual(1, count_sessions()) +class FileSessionPathLibTests(FileSessionTests): + def mkdtemp(self): + tmp_dir = super().mkdtemp() + return Path(tmp_dir) + + class CacheSessionTests(SessionTestsMixin, unittest.TestCase): backend = CacheSession |
