SharedPreferences: fix None handling

This commit is contained in:
Thomas Farstrike
2026-03-11 21:09:43 +01:00
parent 181a10c99b
commit 1bf1dd67f0
2 changed files with 9 additions and 1 deletions
+8
View File
@@ -432,6 +432,14 @@ class TestSharedPreferences(unittest.TestCase):
# Getting a nonexistent key should return None or default
self.assertIsNone(prefs.get_string("nonexistent"))
def test_put_string_none_value(self):
"""Test that putting None stores and returns a real None."""
prefs = SharedPreferences(self.test_app_name)
prefs.edit().put_string("auto_start_app_early", None).commit()
prefs2 = SharedPreferences(self.test_app_name)
self.assertIsNone(prefs2.get_string("auto_start_app_early"))
def test_special_characters_in_keys(self):
"""Test keys with special characters."""
prefs = SharedPreferences(self.test_app_name)