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

Function test_save_with_no_args

tests/test_magic.py:1715–1735  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1713
1714
1715def test_save_with_no_args():
1716 ip = get_ipython()
1717 ip.history_manager.reset() # Clear any existing history.
1718 cmds = ["a=1", "def b():\n return a**2", "print(a, b())", "%save"]
1719 for i, cmd in enumerate(cmds, start=1):
1720 ip.history_manager.store_inputs(i, cmd)
1721
1722 with TemporaryDirectory() as tmpdir:
1723 path = os.path.join(tmpdir, "testsave.py")
1724 ip.run_line_magic("save", path)
1725 content = Path(path).read_text(encoding="utf-8")
1726 expected_content = dedent(
1727 """\
1728 # coding: utf-8
1729 a=1
1730 def b():
1731 return a**2
1732 print(a, b())
1733 """
1734 )
1735 assert content == expected_content
1736
1737
1738def test_store():

Callers

nothing calls this directly

Calls 5

get_ipythonFunction · 0.90
dedentFunction · 0.85
store_inputsMethod · 0.80
run_line_magicMethod · 0.80
resetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…