Exemple #1
0
def test_error_no_action(tmp_ipynb):
    with pytest.raises(ValueError, match="Please provide one of"):
        jupytext([tmp_ipynb])
Exemple #2
0
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"])
Exemple #3
0
def test_error_not_same_ext(tmp_ipynb, tmpdir):
    with pytest.raises(InconsistentPath):
        jupytext([tmp_ipynb, "--to", "py", "-o", str(tmpdir.join("not.md"))])
Exemple #4
0
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'
Exemple #5
0
def test_jupytext_version(capsys):
    jupytext(['--version'])

    out, err = capsys.readouterr()
    assert err == ''
    compare(out, __version__)
Exemple #6
0
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)
Exemple #7
0
 def hook():
     with mock.patch('jupytext.cli.system', system_in_tmpdir):
         jupytext(['--to', 'py', '--pre-commit'])
Exemple #8
0
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)
Exemple #9
0
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)
Exemple #10
0
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)
Exemple #11
0
def test_error_no_action(tmp_ipynb):
    with pytest.raises(ValueError) as info:
        jupytext([tmp_ipynb])

    assert "Please select an action" in str(info)
Exemple #12
0
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)
Exemple #13
0
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)
Exemple #14
0
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)