Ejemplo n.º 1
0
def test_runWithHTMLReturn_pass():
    # checks should pass
    nb = os.path.join(os.path.dirname(__file__), 'more.ipynb')
    html, passed = run(nb, html=True, rules={"cells_per_notebook": 10})
    assert passed is True
    _check(html,
           [("PASSED", "Checking cells per notebook (max=10; actual=4)")])
Ejemplo n.º 2
0
def test_runWithHTMLReturn_fail():
    # checks should fail
    nb = os.path.join(os.path.dirname(__file__), 'more.ipynb')
    html, passed = run(nb,
                       html=True,
                       rules={
                           "cells_per_notebook": 1,
                           "lines_per_cell": 2
                       })
    assert passed is False
    _check(html,
           [("PASSED", "Checking lines in cell (max=2; actual=2)(Cell 1)"),
            ("PASSED", "Checking lines in cell (max=2; actual=1)(Cell 2)"),
            ("PASSED", "Checking lines in cell (max=2; actual=2)(Cell 3)"),
            ("FAILED", "Checking lines in cell (max=2; actual=3)(Cell 4)"),
            ("FAILED", "Checking cells per notebook (max=1; actual=4)")])
Ejemplo n.º 3
0
def test_run(rules, expected_ret, expected_pass):
    nb = os.path.join(os.path.dirname(__file__), 'more.ipynb')
    ret, passed = run(nb, rules=rules)
    _verify(ret, passed, expected_ret, expected_pass)
Ejemplo n.º 4
0
def test_runWithHTMLReturn_norules():
    # no rules, so will pass without any checks
    nb = os.path.join(os.path.dirname(__file__), 'more.ipynb')
    html, passed = run(nb, html=True)
    assert passed is True
    _check(html, [])
Ejemplo n.º 5
0
def test_run(rules, noqa_regex, expected_ret, expected_pass):
    nb = os.path.join(os.path.dirname(__file__), "more.ipynb")
    ret, passed = run(nb, rules=rules, noqa_regex=noqa_regex)
    _verify(ret, passed, expected_ret, expected_pass)