def test_error_no_action(tmp_ipynb): with pytest.raises(ValueError, match="Please provide one of"): jupytext([tmp_ipynb])
def test_error_not_notebook_ext_to(tmp_ipynb): with pytest.raises(JupytextFormatError, match="'ext' is not a notebook extension"): jupytext([tmp_ipynb, "--to", "ext"])
def test_error_not_same_ext(tmp_ipynb, tmpdir): with pytest.raises(InconsistentPath): jupytext([tmp_ipynb, "--to", "py", "-o", str(tmpdir.join("not.md"))])
def test_set_formats_py_file_only(py_file, tmpdir): tmp_py = str(tmpdir.join('notebook.py')) copyfile(py_file, tmp_py) jupytext([tmp_py, '--set-formats', 'ipynb,py:light']) nb = readf(tmp_py) assert nb.metadata['jupytext']['formats'] == 'ipynb,py:light'
def test_jupytext_version(capsys): jupytext(['--version']) out, err = capsys.readouterr() assert err == '' compare(out, __version__)
def test_error_unknown_opt(tmp_ipynb): with pytest.raises(ValueError) as info: jupytext([tmp_ipynb, '--to', 'py', '--opt', 'unknown=true']) assert 'is not a valid format option' in str(info)
def hook(): with mock.patch('jupytext.cli.system', system_in_tmpdir): jupytext(['--to', 'py', '--pre-commit'])
def test_error_multiple_input(tmp_ipynb): with pytest.raises(ValueError) as info: jupytext([tmp_ipynb, tmp_ipynb, '--to', 'py', '-o', 'notebook.py']) assert 'Please input a single notebook when using --output' in str(info)
def test_error_opt_missing_equal(tmp_ipynb): with pytest.raises(ValueError) as info: jupytext([tmp_ipynb, '--to', 'py', '--opt', 'missing_equal']) assert 'key=value' in str(info)
def test_error_update_not_ipynb(tmp_py): with pytest.raises(ValueError) as info: jupytext([tmp_py, '--to', 'py', '--update']) assert '--update is only for ipynb files' in str(info)
def test_error_no_action(tmp_ipynb): with pytest.raises(ValueError) as info: jupytext([tmp_ipynb]) assert "Please select an action" in str(info)
def test_error_not_same_ext(tmp_ipynb, tmpdir): with pytest.raises(ValueError) as info: jupytext([tmp_ipynb, '--to', 'py', '-o', str(tmpdir.join('not.md'))]) assert 'InconsistentPath' in str(info)
def test_error_not_notebook_ext_output(tmp_ipynb, tmpdir): with pytest.raises(JupytextFormatError) as info: jupytext([tmp_ipynb, '-o', str(tmpdir.join('not.ext'))]) assert "Extension '.ext' is not a notebook extension. Please use one of" in str( info)
def test_error_not_notebook_ext_to(tmp_ipynb): with pytest.raises(JupytextFormatError) as info: jupytext([tmp_ipynb, '--to', 'ext']) assert "Extension '.ext' is not a notebook extension. Please use one of" in str( info)