testbook
A unit testing framework for Jupyter Notebooks
Decision gist · record as of 2026-08-14
Yes, with caution. testbook fills a real gap for testing notebook-based code, and the low install friction and permissive license make it accessible. However, the package is dormant—no releases since 2021-06-02—which raises questions about compatibility with modern Python and Jupyter versions. If your notebooks target Python 3.6–3.8 and stable Jupyter dependencies, it should work; for newer environments, verify compatibility before committing to production use.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires a Jupyter kernel installed separately (e.g., ipykernel via pip install ipykernel) to execute notebooks during tests.
- Low friction install with just two runtime dependencies (nbformat, nbclient).
- However, the package is dormant—last release was 2021-06-02, though the repository remains active with a recent commit on 2024-08-25.
License · maintenance · safety
BSD (permissive) — BSD license is permissive, allowing commercial and private use with minimal restrictions. No licensing friction for most use cases.
last release 2021-06-02 (1899 days) · last repo commit 2024-08-25 · 435 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 105,132 downloads/mo, #12,718 on PyPI
Alternatives
Verify before relying
pip install testbook
from testbook import testbook
@testbook('/path/to/notebook.ipynb', execute=True)
def test_func(tb):
func = tb.get("func")
assert func(1, 2) == 3- Whether testbook works with modern Python versions beyond 3.8, given classifiers list only through 3.8
- Current compatibility with recent nbformat and nbclient versions, given no releases since 2021-06-02
- Whether dormant status affects bug fixes or compatibility with newer Jupyter ecosystem changes
What it is and what it does
testbook is a unit testing framework that lets you write conventional Python unit tests for Jupyter Notebooks without embedding tests inside the notebooks themselves. Instead of mixing test code with notebook cells, you write separate test files that load and execute a notebook, then extract and assert on its outputs and variables. It depends on nbformat to parse notebooks and nbclient to execute them, bridging the gap between notebook-based development and traditional test-driven development practices.
The package treats .ipynb files as importable modules within your test suite. You decorate a test function with @testbook, pointing it to a notebook path, and the decorator handles notebook execution and provides a testbook object (tb) that lets you retrieve variables and functions defined in the notebook. This approach is useful for data science and analytics workflows where notebooks are primary development artifacts but you still want automated test coverage.
Use it for
- Test data processing pipelines defined in Jupyter notebooks without rewriting them as Python modules
- Validate notebook outputs and intermediate variables in a CI/CD pipeline
- Ensure notebook functions produce expected results when dependencies or data change
- Build regression tests for analytical or scientific notebooks shared across a team
- Verify notebook cells execute without errors before publishing or sharing them
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, with caution.
testbook fills a real gap for testing notebook-based code, and the low install friction and permissive license make it accessible. However, the package is dormant—no releases since 2021-06-02—which raises questions about compatibility with modern Python and Jupyter versions. If your notebooks target Python 3.6–3.8 and stable Jupyter dependencies, it should work; for newer environments, verify compatibility before committing to production use.
Install
testbook on PyPI
Before you install
Low friction install with just two runtime dependencies (nbformat, nbclient). However, the package is dormant—last release was 2021-06-02, though the repository remains active with a recent commit on 2024-08-25. No active maintenance signal.
Requires a Jupyter kernel installed separately (e.g., ipykernel via pip install ipykernel) to execute notebooks during tests.
License in practice
BSD license is permissive, allowing commercial and private use with minimal restrictions. No licensing friction for most use cases.
Quickstart
pip install testbook
from testbook import testbook
@testbook('/path/to/notebook.ipynb', execute=True)
def test_func(tb):
func = tb.get("func")
assert func(1, 2) == 3
Verify before relying
- Whether testbook works with modern Python versions beyond 3.8, given classifiers list only through 3.8
- Current compatibility with recent nbformat and nbclient versions, given no releases since 2021-06-02
- Whether dormant status affects bug fixes or compatibility with newer Jupyter ecosystem changes
Package facts
| License | BSD permissive |
| Python support | Supports the current Python release >=3.6 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 2 packagesnbformatnbclient |
| Maintenance | Dormant 1,899 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 105,132 / month, #12,718 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Intended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8 |
Evidence: testbook-0.4.2-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “jupyter notebook unit testing”
- testbooktestbook lets you write unit tests for Jupyter Notebooks in separate…
- ipytestRuns pytest test suites directly in Jupyter notebooks with full…
- importnbimportnb lets you import Jupyter notebooks as Python modules, making…
Give your agent the search over MCP, or paste the wish link into any chat.
More Testing packages
Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.
Install it if you're building an extensible application or framework.
pytest is a testing framework that lets you write test functions using plain assert statements and automatically discovers and runs them, with detailed failure reporting.
virtualenv creates isolated Python environments where packages can be installed independently without affecting the system Python or other projects.
Coverage.py measures which lines of Python code are executed during test runs, reporting coverage percentages and identifying untested code paths.
Install it if you want to measure test completeness or enforce coverage thresholds in your project.
pytest-asyncio is a pytest plugin that enables writing and running async test functions using the asyncio library, allowing developers to await code directly within test cases.
Install it if you write tests for any asyncio-based code.
A pytest plugin that generates test reports in Common Test Report Format (CTRF) as JSON, compatible with pytest-xdist and pytest-playwright for distributed and browser-based testing.
Install it if you need CTRF-formatted test output for CI/CD integration or cross-tool reporting.
See also nbval · scrapbook · nbmake · importnb · ipynb · FMPy · mkdocs-jupyter · ipytest · papermill · nbsphinx