The functions that grab the cells containing tests (filtering with potential flags) and execute them

Everything that is not an exported cell is considered a test, so you should make sure your notebooks can all run smoothly (and fast) if you want to use this functionality as the CLI. You can mark some cells with special flags (like slow) to make sure they are only executed when you authorize it. Those flags should be configured in your settings.ini (separated by a | if you have several of them). You can also apply flags to one entire notebook by putting any number of "all flags", e.g. # all_flag, in code cells.

Detect flags

The following functions detect the cells that should be excluded from the tests (unless their special flag is passed).



Check for all test flags in cells

nb = read_nb("04_test.ipynb")
assert get_all_flags(nb['cells']) == set()



Check for any special test flag in cell

test_eq(get_cell_flags({'cell_type': 'code', 'source': "#hide\n# fastai2\n"}), ['fastai2'])
test_eq(get_cell_flags({'cell_type': 'code', 'source': "#hide\n"}), [])

Testing a notebook

class NoExportPreprocessor[source]

NoExportPreprocessor(*args, **kwargs) :: ExecutePreprocessor

An ExecutePreprocessor that executes cells that don't have a flag in flags


test_nb(fn, flags=None)

Execute tests in notebook in fn with flags