Skip to content

Commit

Permalink
Add test for __main__ invocation
Browse files Browse the repository at this point in the history
Test invocation via `python -m jupytext`.
  • Loading branch information
matthew-brett committed Feb 10, 2021
1 parent 679b1c9 commit 2f4cda8
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from argparse import ArgumentTypeError
from io import StringIO
from shutil import copyfile
from subprocess import check_call

import nbformat
import pytest
Expand Down Expand Up @@ -65,6 +66,24 @@ def test_convert_single_file_in_place(nb_file, tmpdir):
compare_notebooks(nb2, nb1)


def test_convert_single_file_in_place_m(tmpdir):
nb_file = list_notebooks("ipynb_py")[0]
nb_org = str(tmpdir.join(os.path.basename(nb_file)))
copyfile(nb_file, nb_org)

base, ext = os.path.splitext(nb_org)

for fmt_ext in ("py", "Rmd"):
nb_other = base + "." + fmt_ext

check_call([sys.executable, "-m", "jupytext", nb_org, "--to", fmt_ext])

nb1 = read(nb_org)
nb2 = read(nb_other)

compare_notebooks(nb2, nb1)


@pytest.mark.parametrize("nb_file", list_notebooks("ipynb") + list_notebooks("Rmd"))
def test_convert_single_file(nb_file, tmpdir, capsys):
nb_org = str(tmpdir.join(os.path.basename(nb_file)))
Expand Down

0 comments on commit 2f4cda8

Please sign in to comment.