test_nb
test_nb (fn, skip_flags=None, force_flags=None, do_print=False, showerr=True)
Execute tests in notebook in fn
except those with skip_flags
test_nb (fn, skip_flags=None, force_flags=None, do_print=False, showerr=True)
Execute tests in notebook in fn
except those with skip_flags
test_nb can test a notebook, and skip over certain flags:
_nb = Path('../tests/directives.ipynb')
success,duration = test_nb(_nb, skip_flags=['notest'])
assert success
duration
0.021807193756103516
In that notebook the cell flagged notest raises an exception, which will be returned as a bool
:
Sometimes you may wish to override one or more of the skip_flags, in which case you can use the argument force_flags
which will remove the appropriate tag(s) from skip_flags
. This is useful because skip_flags
are meant to be set in the tst_flags
field of settings.ini
, whereas force_flags
are usually passed in by the user.
nbprocess_test (fname:str=None, flags:str='', n_workers:int=None, timing:bool=False, do_print:bool=False, pause:float=0.01, symlinks:bool=False, recursive:bool=None, file_re:str=None, folder_re:str=None, skip_file_glob:str=None, skip_file_re:str='^[_.]', ignore_fname:str='.notest')
Test in parallel the notebooks matching fname
, passing along flags
Type | Default | Details | |
---|---|---|---|
fname | str | None | A notebook name or glob to test |
flags | str | Space separated list of test flags you want to run that are normally ignored | |
n_workers | int | None | Number of workers to use |
timing | bool | False | Timing each notebook to see the ones are slow |
do_print | bool | False | Print start and end of each NB |
pause | float | 0.01 | Pause time (in secs) between notebooks to avoid race conditions |
symlinks | bool | False | Follow symlinks? |
recursive | bool | None | Include subfolders? |
file_re | str | None | Only include files matching regex |
folder_re | str | None | Only enter folders matching regex |
skip_file_glob | str | None | Skip files matching glob |
skip_file_re | str | 1 | Skip files matching regex |
ignore_fname | str | .notest | filename that will result in siblings being ignored |
_.↩︎