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 a flag to one entire notebook by putting # all_flag in one of its cells.

Detect flags

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

check_all_flag[source]

check_all_flag(cells)

Check for an # all_flag cell and then return said flag

nb = read_nb("04_test.ipynb")
assert check_all_flag(nb['cells']) is None

get_cell_flags[source]

get_cell_flags(cell)

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 are not exported and don't have a flag in flags

test_nb[source]

test_nb(fn, flags=None)

Execute tests in notebook in fn with flags