diff options
| author | Amar <100243770+aadeina@users.noreply.github.com> | 2026-02-03 00:34:04 +0000 |
|---|---|---|
| committer | Jacob Walls <jacobtylerwalls@gmail.com> | 2026-02-21 09:57:49 -0500 |
| commit | 158fd81ef5a5647d27eb3065063284f9ee0a3ca4 (patch) | |
| tree | c6a2bc932dd9d54fb6eb25be7a4e8299babeb0e5 /tests | |
| parent | e85db77e11e37d6ec82526557c4dafe4b30dc699 (diff) | |
Fixed #36899 -- Implemented SessionBase.__bool__.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/sessions_tests/tests.py | 11 |
1 files changed, 11 insertions, 0 deletions
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) |
