A unit testing framework for Jupyter Notebooks. Current version 0.4.2 (release cadence: infrequent, last release Sep 2021). Allows writing and running tests for notebook cells using Python test frameworks.
pip install testbookVerified import paths — ran on the pinned version, not inferred.
Decorate a test function with @testbook, specifying the notebook path. The test function receives a Testbook object. Calling tb.cell_output(index) retrieves the output of a cell.
Set execute=False in the decorator: @testbook('notebook.ipynb', execute=False), then run tb.execute_cell(0) to run specific cells in your test.Use tb.cell_output_slice() or iterate with tb.cells to find the correct index. Alternatively, use cell tags in the notebook to reference cells by name.
Update imports: from testbook import testbook. Use @testbook decorator or context manager.
Install testbook: pip install testbook
Use: from testbook import testbook
Use an absolute path or set the working directory to the notebook's location.
No dependency data recorded yet.