Exemplo n.º 1
0
def test_error_no_action(tmp_ipynb):
    with pytest.raises(ValueError, match="Please provide one of"):
        jupytext([tmp_ipynb])
Exemplo n.º 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"])
Exemplo n.º 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"))])
Exemplo n.º 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'
Exemplo n.º 5
0
def test_jupytext_version(capsys):
    jupytext(['--version'])

    out, err = capsys.readouterr()
    assert err == ''
    compare(out, __version__)
Exemplo n.º 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)
Exemplo n.º 7
0
 def hook():
     with mock.patch('jupytext.cli.system', system_in_tmpdir):
         jupytext(['--to', 'py', '--pre-commit'])
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)