MCPcopy Index your code
hub / github.com/ipython/ipython / test_magic_warnings

Function test_magic_warnings

tests/test_interactiveshell.py:702–715  ·  view source on GitHub ↗
(magic_cmd)

Source from the content-addressed store, hash-verified

700
701@pytest.mark.parametrize("magic_cmd", ["pip", "conda", "cd"])
702def test_magic_warnings(magic_cmd):
703 if sys.platform == "win32":
704 to_mock = "os.system"
705 expected_arg, expected_kwargs = magic_cmd, dict()
706 else:
707 to_mock = "subprocess.call"
708 expected_arg, expected_kwargs = magic_cmd, dict(
709 shell=True, executable=os.environ.get("SHELL", None)
710 )
711
712 with mock.patch(to_mock, return_value=0) as mock_sub:
713 with pytest.warns(Warning, match=r"You executed the system command"):
714 ip.system_raw(magic_cmd)
715 mock_sub.assert_called_once_with(expected_arg, **expected_kwargs)
716
717
718# TODO: Exit codes are currently ignored on Windows.

Callers

nothing calls this directly

Calls 2

getMethod · 0.80
system_rawMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…