A unit testing framework for Jupyter Notebooks
Likely abandoned. No release or commit for years (last release over 5 years ago).
pip install testbooktestbook
testbook is a unit testing framework extension for testing code in Jupyter Notebooks.
Previous attempts at unit testing notebooks involved writing the tests in the notebook itself. However, testbook will allow for unit tests to be run against notebooks in separate test files, hence treating .ipynb files as .py files.
testbook helps you set up conventional unit tests for your Jupyter Notebooks.
Here is an example of a unit test written using testbook
Consider the following code cell in a Jupyter Notebook:
def func(a, b):
return a + b
You would write a unit test using testbook in a Python file as follows:
from testbook import testbook
@testbook('/path/to/notebook.ipynb', execute=True)
def test_func(tb):
func = tb.get("func")
assert func(1, 2) == 3
Installing testbook
pip install testbook
NOTE: This does not install any kernels for running your notebooks. You'll need to install in the same way you do for running the notebooks normally. Usually this is done with