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 5b01d1a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 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
8 changes: 8 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
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 5b01d1a

Please sign in to comment.