From 158fd81ef5a5647d27eb3065063284f9ee0a3ca4 Mon Sep 17 00:00:00 2001 From: Amar <100243770+aadeina@users.noreply.github.com> Date: Tue, 3 Feb 2026 00:34:04 +0000 Subject: Fixed #36899 -- Implemented SessionBase.__bool__. --- tests/sessions_tests/tests.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests') diff --git a/tests/sessions_tests/tests.py b/tests/sessions_tests/tests.py index 81c2e7a5de..f23fa9778d 100644 --- a/tests/sessions_tests/tests.py +++ b/tests/sessions_tests/tests.py @@ -1373,3 +1373,14 @@ class SessionBaseTests(SimpleTestCase): def test_is_empty(self): self.assertIs(self.session.is_empty(), True) + + def test_bool(self): + # Empty session is falsy + self.assertIs(bool(self.session), False) + # Session with data is truthy + self.session["foo"] = "bar" + self.assertIs(bool(self.session), True) + # Session with key but no data is truthy + session_with_key = SessionBase() + session_with_key._session_key = "testkey1234" + self.assertIs(bool(session_with_key), True) -- cgit v1.3