Пример #1
0
def test_run_notebook_node():
    notebook_node = utils.make_notebook_node(["2 + 2"])

    utils.run_notebook_node(notebook_node)

    output = notebook_node.cells[0].outputs[0]
    assert output.data["text/plain"] == "4"
Пример #2
0
def test_get_returned_output_text():
    notebook_node = utils.make_notebook_node(['2 + 2'])
    utils.run_notebook_node(notebook_node)

    output_text = utils.get_output_text(notebook_node.cells[0])

    assert "4" in output_text
Пример #3
0
def test_get_printed_output_text():
    notebook_node = utils.make_notebook_node(
        ['print("Some numbers:")\nfor num in range(6):\n\tprint(num)'])
    utils.run_notebook_node(notebook_node)

    output_text = utils.get_output_text(notebook_node.cells[0])

    assert "4" in output_text
Пример #4
0
def test_run_notebook_node_allows_warnings():
    cell_input = ("import warnings\n"
                  "warnings.warn(\"deprecated\", DeprecationWarning)")
    notebook_node = utils.make_notebook_node([cell_input])

    utils.run_notebook_node(notebook_node)
Пример #5
0
def test_run_notebook_node_can_allow_errors(cell_input):
    notebook_node = utils.make_notebook_node([cell_input])

    utils.run_notebook_node(notebook_node, allow_errors=True)
Пример #6
0
def test_run_notebook_node_disallows_errors_by_default(cell_input):
    notebook_node = utils.make_notebook_node([cell_input])

    with pytest.raises(CellExecutionError):
        utils.run_notebook_node(notebook_node)