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 using the all
option, e.g. #all_slow
, in code cells.
If tst_flags=slow|fastai
in settings.ini
, you can:
- mark slow tests with
#slow
flag - mark tests that depend on fastai with the
#fastai
flag.
The following functions detect the cells that should be excluded from the tests (unless their special flag is passed).
nb = read_nb("04_test.ipynb")
assert get_all_flags(nb['cells']) == set()
test_eq(get_cell_flags({'cell_type': 'code', 'source': "#hide\n"}), [])
test_nb('index.ipynb')