()
| 1713 | |
| 1714 | |
| 1715 | def 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 | |
| 1738 | def test_store(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…