summaryrefslogtreecommitdiff
path: root/tests/shell
diff options
context:
space:
mode:
authorNatalia <124304+nessita@users.noreply.github.com>2025-02-07 14:18:54 -0300
committernessita <124304+nessita@users.noreply.github.com>2025-02-10 22:58:26 -0300
commit44ccd20375ba0d4da869ef994bc10a2311e9dc88 (patch)
tree2a3da1b4d0725011df09b9d51975ddfe93f9c94a /tests/shell
parent3839afb63ad5183cdf08e06e3a43a014ca4b7263 (diff)
Refs #35515 -- Refactored internal `get_and_report_namespace` in the shell command.
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