Unit Testing Jupyter Notebooks - testbook
summary
testbook is a unit-testing library that treats .ipynb files like .py modules by creating remote reference objects in the notebook kernel, injecting test code and running assertions inside that kernel so complex objects (dataframes, mocks) never need serializing. Features include cell-level execution, shared kernel fixtures, and patching of notebook functions; it already powers automated grading at scale and integrates with pytest/unittest, though it currently flags compatibility issues with ipykernel 5.5.
AI-written summary · about
chapters (22)
- 0:00Intro
- 0:14Unit Testing Jupyter Notebooks - testbook
- 3:13What is a Notebook?
- 3:41A simple unit test using testbook
- 4:32Another example
- 5:11Running a Test Suite
- 5:37Write conventional unit tests for Jupyter Notebool
- 6:04Execute all or some specific cells before unit test
- 6:34Share kernel context across multiple tests
- 7:05Perform patching of objects in the notebook
- 7:45Inject code into Jupyter notebooks
- 9:07Works with any unit testing library
- 9:31Tests from Testbook's Git
- 12:10Writing quality Jupyter Notebooks
- 13:08Jupyter Notebooks can get very messy
- 14:03Why Test?
- 14:47Test driven development for Jupyter Notebooks?
- 16:58How testbook works
- 19:50Push down to kernel
- 20:29Who Should Use Testbook?
- 22:01Real World Use case: Autograding notebooks
- 23:09What's Coming Up?
related talks
02h 13mPython Unit Testing with Pytest and Mock
27mWriting a Book in Jupyter Notebooks
39mClean Code in Jupyter notebooks, using Python
24mAutomated Regression Testing with Splinter and Jupyter
49mBest tools for Jupyter notebooks
39mUnit Testing for Data Scientists
43mJupyter: Notebooks in Multiple Languages for Data Science
24mTesting Your Python Code
