From b11ec9a69ef626bd7aa22879145e9d74ea38a814 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Freitag?= Date: Mon, 18 May 2020 22:11:46 +0200 Subject: Fixed #32301 -- Made clearsessions raise CommandError when clear_expired() is not implemented. --- tests/sessions_tests/tests.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests/sessions_tests/tests.py') diff --git a/tests/sessions_tests/tests.py b/tests/sessions_tests/tests.py index 2832fd8970..73d2a13a9f 100644 --- a/tests/sessions_tests/tests.py +++ b/tests/sessions_tests/tests.py @@ -910,3 +910,14 @@ class CookieSessionTests(SessionTestsMixin, SimpleTestCase): @unittest.skip("CookieSession is stored in the client and there is no way to query it.") def test_session_save_does_not_resurrect_session_logged_out_in_other_context(self): pass + + +class ClearSessionsCommandTests(SimpleTestCase): + def test_clearsessions_unsupported(self): + msg = ( + "Session engine 'tests.sessions_tests.no_clear_expired' doesn't " + "support clearing expired sessions." + ) + with self.settings(SESSION_ENGINE='tests.sessions_tests.no_clear_expired'): + with self.assertRaisesMessage(management.CommandError, msg): + management.call_command('clearsessions') -- cgit v1.2.1