Skip to content

Commit

Permalink
Improve error message when only --test is passed
Browse files Browse the repository at this point in the history
  • Loading branch information
mwouts committed Oct 20, 2019
1 parent 7f282fa commit 08e50f9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
7 changes: 5 additions & 2 deletions jupytext/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,15 @@ def log(text):
print_paired_paths(args.notebooks[0], args.input_format)
return 1

if (args.test or args.test_strict) and not args.to and not args.output and not args.sync:
raise ValueError('Please provide one of --to, --output or --sync')

if not args.to and not args.output and not args.sync \
and not args.pipe and not args.check \
and not args.test and not args.test_strict \
and not args.update_metadata and not args.set_kernel \
and not args.execute:
raise ValueError('Please select an action')
raise ValueError('Please provide one of --to, --output, --sync, --pipe, '
'--check, --update_metadata, --set-kernel or --execute')

if args.output and len(args.notebooks) != 1:
raise ValueError('Please input a single notebook when using --output')
Expand Down
10 changes: 9 additions & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def test_error_not_same_ext(tmp_ipynb, tmpdir):


def test_error_no_action(tmp_ipynb):
with pytest.raises(ValueError, match="Please select an action"):
with pytest.raises(ValueError, match="Please provide one of"):
jupytext([tmp_ipynb])


Expand Down Expand Up @@ -982,3 +982,11 @@ def erroneous_is_magic(line, language, comment_magics):

with mock.patch('jupytext.magics.is_magic', erroneous_is_magic):
assert jupytext([tmp_py, '--to', 'ipynb', '--test-strict']) != 0


def test_339_require_to(tmpdir):
"""Test that the to argument is asked for when a `--test` command is provided"""
tmp_py = str(tmpdir.join('test.py'))

with pytest.raises(ValueError, match='--to'):
jupytext([tmp_py, '--test-strict'])

0 comments on commit 08e50f9

Please sign in to comment.