summaryrefslogtreecommitdiff
path: root/tests/shell
diff options
context:
space:
mode:
authorNatalia <124304+nessita@users.noreply.github.com>2025-02-07 14:18:54 -0300
committerNatalia <124304+nessita@users.noreply.github.com>2025-02-10 22:59:33 -0300
commit7b0c587a68c2e486ccf8c967de55e0a66f8e5a2a (patch)
treed9d6a82eab812acb9e04ce7ca221bb1abc6eba16 /tests/shell
parent0125bc15d4d0de9d92078dc17464bb749567ca99 (diff)
[5.2.x] Refs #35515 -- Refactored internal `get_and_report_namespace` in the shell command.
Backport of 44ccd20375ba0d4da869ef994bc10a2311e9dc88 from main.
Diffstat (limited to 'tests/shell')
-rw-r--r--tests/shell/tests.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/tests/shell/tests.py b/tests/shell/tests.py
index 49528cca8e..3ca12edfed 100644
--- a/tests/shell/tests.py
+++ b/tests/shell/tests.py
@@ -85,13 +85,14 @@ class ShellCommandTestCase(SimpleTestCase):
def test_ipython(self):
cmd = shell.Command()
mock_ipython = mock.Mock(start_ipython=mock.MagicMock())
+ options = {"verbosity": 0, "no_imports": False}
with mock.patch.dict(sys.modules, {"IPython": mock_ipython}):
- cmd.ipython({"verbosity": 0, "no_imports": False})
+ cmd.ipython(options)
self.assertEqual(
mock_ipython.start_ipython.mock_calls,
- [mock.call(argv=[], user_ns=cmd.get_and_report_namespace(0))],
+ [mock.call(argv=[], user_ns=cmd.get_and_report_namespace(**options))],
)
@mock.patch("django.core.management.commands.shell.select.select") # [1]
@@ -106,12 +107,14 @@ class ShellCommandTestCase(SimpleTestCase):
def test_bpython(self):
cmd = shell.Command()
mock_bpython = mock.Mock(embed=mock.MagicMock())
+ options = {"verbosity": 0, "no_imports": False}
with mock.patch.dict(sys.modules, {"bpython": mock_bpython}):
- cmd.bpython({"verbosity": 0, "no_imports": False})
+ cmd.bpython(options)
self.assertEqual(
- mock_bpython.embed.mock_calls, [mock.call(cmd.get_and_report_namespace(0))]
+ mock_bpython.embed.mock_calls,
+ [mock.call(cmd.get_and_report_namespace(**options))],
)
@mock.patch("django.core.management.commands.shell.select.select") # [1]
@@ -126,13 +129,14 @@ class ShellCommandTestCase(SimpleTestCase):
def test_python(self):
cmd = shell.Command()
mock_code = mock.Mock(interact=mock.MagicMock())
+ options = {"verbosity": 0, "no_startup": True, "no_imports": False}
with mock.patch.dict(sys.modules, {"code": mock_code}):
- cmd.python({"verbosity": 0, "no_startup": True, "no_imports": False})
+ cmd.python(options)
self.assertEqual(
mock_code.interact.mock_calls,
- [mock.call(local=cmd.get_and_report_namespace(0))],
+ [mock.call(local=cmd.get_and_report_namespace(**options))],
)
# [1] Patch select to prevent tests failing when the test suite is run