Skip to content

Commit 76161d4

Browse files
TTTPOBclaude
andcommitted
test(notebook_writeback): update no-writeback test to use a plain script
test_no_writeback_without_paired_ipynb used a py:percent file (with front matter + # %%) which now correctly triggers auto-creation. Replace with test_no_writeback_for_plain_script that uses a bare .py with no markers — the boundary condition this test was always meant to cover. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent d1a0d5e commit 76161d4

1 file changed

Lines changed: 6 additions & 12 deletions

File tree

tests/test_notebook_writeback.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,27 +94,21 @@ def test_writeback_multiple_cells(self, live_session, mock_kernel_connection, tm
9494
assert any("20" in str(o) for o in updated_nb.cells[1].outputs)
9595
assert any("30" in str(o) for o in updated_nb.cells[2].outputs)
9696

97-
def test_no_writeback_without_paired_ipynb(self, live_session, mock_kernel_connection, tmp_path):
97+
def test_no_writeback_for_plain_script(self, live_session, mock_kernel_connection, tmp_path):
98+
"""Plain Python scripts (no # %% markers, no front matter) never create a notebook."""
9899
runner = CliRunner()
99100
py_file = tmp_path / "standalone.py"
100-
py_file.write_text(textwrap.dedent("""\
101-
# ---
102-
# jupyter:
103-
# kernelspec:
104-
# name: python3
105-
# ---
106-
107-
# %%
108-
print("no paired notebook")
109-
"""))
101+
py_file.write_text('print("no paired notebook")\n')
110102

111103
result = runner.invoke(main, [
112104
"-s", live_session["url"], "-t", live_session["token"],
113-
"exec", live_session["session_id"], "--file", str(py_file), "--cell", "0",
105+
"exec", live_session["session_id"], "--file", str(py_file),
114106
])
115107
assert result.exit_code == 0
116108
assert "no paired notebook" in result.output
117109
assert "Notebook updated" not in result.output
110+
assert "Notebook created" not in result.output
111+
assert not (tmp_path / "standalone.ipynb").exists()
118112

119113

120114
class TestIpynbWriteback:

0 commit comments

Comments
 (0)