diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 6db00c2e0..285fd526d 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -13,6 +13,7 @@ Jupytext ChangeLog **Added** - We now test Jupytext against Python 3.6 to 3.11 on the CI +- We have added a test to document how to use the folder and prefix matching when pairing notebooks ([#974](https://github.com/mwouts/jupytext/issues/974)) 1.14.1 (2022-07-29) diff --git a/tests/test_cli.py b/tests/test_cli.py index d9900674b..1b613b175 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -807,6 +807,37 @@ def test_cli_sync_file_with_suffix(tmpdir, cwd_tmpdir): fp.read().splitlines()[-4:] == ["", "```{python}", "1+1", "```"] +def test_cli_sync_file_with_prefix_974(tmp_path, python_notebook): + """Only the files that are in the example directory and that start with 'example' should be paired""" + (tmp_path / "pyproject.toml").write_text( + """[tool.jupytext] +formats = "examples//example/ipynb,examples//example/py:percent" +""" + ) + + write(python_notebook, tmp_path / "example_notebook.ipynb") + (tmp_path / "examples" / "folder1").mkdir(parents=True) + write(python_notebook, tmp_path / "examples/folder1/utils.py") + write(python_notebook, tmp_path / "examples/folder1/example_paired.ipynb") + + jupytext( + [ + "--sync", + str(tmp_path / "example_notebook.ipynb"), + str(tmp_path / "examples/folder1/utils.py"), + str(tmp_path / "examples/folder1/example_paired.ipynb"), + ] + ) + + assert not ( + tmp_path / "example_notebook.py" + ).exists(), "Not in the 'examples' directory" + assert not ( + tmp_path / "examples/folder1/utils_not_paired.ipynb" + ).exists(), "Not with the 'example' prefix" + assert (tmp_path / "examples/folder1/example_paired.py").exists(), "Paired" + + @requires_sphinx_gallery def test_rst2md(tmpdir, cwd_tmpdir): tmp_py = "notebook.py"