diff options
| author | Tommy Allen <tommy@esdf.io> | 2024-11-26 15:15:00 -0500 |
|---|---|---|
| committer | Natalia <124304+nessita@users.noreply.github.com> | 2024-11-26 17:16:30 -0300 |
| commit | 4b262408aa6dadea9ca80c4e1ccc9a046fb07583 (patch) | |
| tree | 5e447b0c71dcd1610dd3eea5edf64a204a6ca7b8 /tests | |
| parent | 08ac8c1b4416d1fba39f86dd328017ca74abce67 (diff) | |
[5.1.x] Fixed #35942 -- Fixed createsuperuser crash on Python 3.13+ when username is unavailable.
Thanks Mariusz Felisiak and Jacob Tyler Walls for reviews.
Backport of c635decb00ac957daf81c08541cdc9cf46f6d86d from main.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/auth_tests/test_management.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/auth_tests/test_management.py b/tests/auth_tests/test_management.py index 5765c50034..0ef85a7299 100644 --- a/tests/auth_tests/test_management.py +++ b/tests/auth_tests/test_management.py @@ -126,6 +126,13 @@ class GetDefaultUsernameTestCase(TestCase): def test_actual_implementation(self): self.assertIsInstance(management.get_system_username(), str) + def test_getuser_raises_exception(self): + # TODO: Drop ImportError and KeyError when dropping support for PY312. + for exc in (ImportError, KeyError, OSError): + with self.subTest(exc=str(exc)): + with mock.patch("getpass.getuser", side_effect=exc): + self.assertEqual(management.get_system_username(), "") + def test_simple(self): management.get_system_username = lambda: "joe" self.assertEqual(management.get_default_username(), "joe") |
