Example #1
0
def test_convert_single_file(nb_file, capsys):
    nb1 = readf(nb_file)
    pynb = writes(nb1, ext='.py')
    convert_notebook_files([nb_file], ext='.py', output='-')

    out, err = capsys.readouterr()
    assert err == ''
    compare(out, pynb)
Example #2
0
def test_convert_single_file_in_place(nb_file, tmpdir):
    nb_org = str(tmpdir.join(os.path.basename(nb_file)))
    base, ext = os.path.splitext(nb_org)
    nb_other = base + '.py'

    copyfile(nb_file, nb_org)
    convert_notebook_files([nb_org], ext='.py')

    nb1 = readf(nb_org)
    nb2 = readf(nb_other)

    compare_notebooks(nb1, nb2)
Example #3
0
def test_convert_multiple_file(nb_files, tmpdir):
    nb_orgs = []
    nb_others = []

    for nb_file in nb_files:
        nb_org = str(tmpdir.join(os.path.basename(nb_file)))
        base, ext = os.path.splitext(nb_org)
        nb_other = base + '.py'
        copyfile(nb_file, nb_org)
        nb_orgs.append(nb_org)
        nb_others.append(nb_other)

    convert_notebook_files(nb_orgs, ext='.py')

    for nb_org, nb_other in zip(nb_orgs, nb_others):
        nb1 = readf(nb_org)
        nb2 = readf(nb_other)
        compare_notebooks(nb1, nb2)
Example #4
0
def test_error_not_same_ext(nb_file=list_notebooks()[0]):
    with pytest.raises(TypeError):
        convert_notebook_files([nb_file], ext='.py', output='not.ext')
Example #5
0
def test_error_not_notebook_ext_dest1(nb_file=list_notebooks()[0]):
    with pytest.raises(TypeError):
        convert_notebook_files([nb_file], ext='.ext')
Example #6
0
def test_error_not_notebook_ext_input(nb_file='notebook.ext'):
    with pytest.raises(TypeError):
        convert_notebook_files([nb_file], ext='.py')
Example #7
0
def test_error_multiple_input(nb_files=list_notebooks()):
    with pytest.raises(ValueError):
        convert_notebook_files(nb_files, ext='.py', output='notebook.py')
Example #8
0
def test_error_multiple_input(nb_files=list_all_notebooks('.ipynb')):
    with pytest.raises(ValueError):
        convert_notebook_files(nb_files, 'notebook.py')
Example #9
0
def test_error_not_notebook_ext_dest(nb_file=list_all_notebooks('.ipynb')[0]):
    with pytest.raises(TypeError):
        convert_notebook_files([nb_file], '.ext')