예제 #1
0
def test_run(files):
    nb_path = files / "original" / "nb0.ipynb"
    nb_ref_path = files / "run" / "nb0.ipynb"
    nb_save_path = files / "run" / "nb0_run.ipynb"
    nb = Notebook(nb_path)
    asyncio.run(nb.run_all())
    nb.save(nb_save_path)
    nb_ref = nb_ref_path.read_text()
    nb_run = nb_save_path.read_text()
    assert nb_ref == nb_run
예제 #2
0
def test_edit0(files):
    nb_path = files / "original" / "nb0.ipynb"
    nb_ref_path = files / "edited" / "nb0.ipynb"
    nb_save_path = files / "edited" / "nb0_edited0.ipynb"
    nb = Notebook(nb_path, no_kernel=True)
    nb.move_down()
    nb.go_down()
    nb.move_up()
    nb.save(nb_save_path)
    nb_ref = nb_ref_path.read_text()
    nb_edited = nb_save_path.read_text()
    assert nb_ref == nb_edited
예제 #3
0
def test_run():
    dir_path = os.path.dirname(os.path.realpath(__file__))
    nb_path = os.path.join(dir_path, "files", "original", "nb0.ipynb")
    nb_ref_path = os.path.join(dir_path, "files", "run", "nb0.ipynb")
    nb_save_path = os.path.join(dir_path, "files", "run", "nb0_run.ipynb")
    nb = Notebook(nb_path)
    nb.run(save_path=nb_save_path)
    with open(nb_ref_path) as f:
        nb_ref = f.read()
    with open(nb_save_path) as f:
        nb_run = f.read()
    assert nb_ref == nb_run
예제 #4
0
def test_edit():
    dir_path = os.path.dirname(os.path.realpath(__file__))
    nb_path = os.path.join(dir_path, "files", "original", "nb0.ipynb")
    nb_ref_path = os.path.join(dir_path, "files", "edited", "nb0.ipynb")
    nb_save_path = os.path.join(dir_path, "files", "edited", "nb0_edited.ipynb")
    nb = Notebook(nb_path, no_kernel=True)
    nb.move_down()
    nb.go_down()
    nb.move_up()
    nb.save(nb_save_path)
    with open(nb_ref_path) as f:
        nb_ref = f.read()
    with open(nb_save_path) as f:
        nb_edited = f.read()
    assert nb_ref == nb_edited
예제 #5
0
def test_edit1(files):
    nb_path = files / "original" / "nb0.ipynb"
    nb_ref_path = files / "edited" / "nb0.ipynb"
    nb_save_path = files / "edited" / "nb0_edited1.ipynb"
    nb = Notebook(nb_path, no_kernel=True)
    nb.cut_cell(0)
    nb.paste_cell(2)
    nb.save(nb_save_path)
    nb_ref = nb_ref_path.read_text()
    nb_edited = nb_save_path.read_text()
    assert nb_ref == nb_edited
예제 #6
0
파일: test_edit.py 프로젝트: zkan/nbterm
def test_edit1():
    dir_path = os.path.dirname(os.path.realpath(__file__))
    nb_path = os.path.join(dir_path, "files", "original", "nb0.ipynb")
    nb_ref_path = os.path.join(dir_path, "files", "edited", "nb0.ipynb")
    nb_save_path = os.path.join(dir_path, "files", "edited",
                                "nb0_edited1.ipynb")
    nb = Notebook(nb_path, no_kernel=True)
    nb.cut_cell(0)
    nb.paste_cell(2)
    nb.save(nb_save_path)
    with open(nb_ref_path) as f:
        nb_ref = f.read()
    with open(nb_save_path) as f:
        nb_edited = f.read()
    assert nb_ref == nb_edited