ipytest
Unit tests in IPython notebooks
What it is and what it does
ipytest bridges pytest and Jupyter notebooks, letting you write and run unit tests interactively without leaving the notebook environment. It registers pytest's assertion rewriter with IPython for better error messages, handles the notebook-to-module mapping pytest needs, and cleans up test state between cell executions to avoid stale test definitions.
The package depends on ipython, packaging, and pytest. It's designed to make it easy to prototype tests in notebooks and later move them to separate test files. It handles common notebook gotchas like module caching and async event loop interference, offering options like force_reload() and run_in_thread mode to work around them.
Use it for:
- Prototyping unit tests interactively in a notebook before moving them to a dedicated test file.
- Teaching or documenting code behavior by writing and running tests inline with explanatory text.
- Testing data science or analysis code iteratively without switching between notebook and terminal.
- Debugging test failures by running pytest with full notebook context and repl access.
- Validating module behavior during development when using IPython's autoreload extension.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Runs pytest test suites directly in Jupyter notebooks with full pytest functionality, including assertion rewriting and test discovery.
Yes, if you work in Jupyter notebooks and want to run pytest without leaving the environment. The package is stable, has no known vulnerabilities, and low install friction. The 845-day dormancy is a minor concern but not a blocker for a mature, narrow-scope tool. Install it if interactive testing in notebooks fits your workflow; skip it if you already run tests in a separate CI/test runner.
Install
ipytest on PyPI
pip
pip install ipytestuv
uv add ipytestpoetry
poetry add ipytestInstalling ipytest
Before you install
Low install friction with a pure-Python wheel. Maintenance is dormant (845 days since last release), but the package is stable and supports current Python versions (3.8–3.12).
License in practice
MIT license is permissive; you can use, modify, and distribute ipytest freely in commercial and private projects with minimal restrictions.
Quickstart
pip install ipytest
import ipytest
ipytest.autoconfig()
# In a new cell:
%%ipytest -qq
def test_example():
assert [1, 2, 3] == [1, 2, 3]
Requires IPython/Jupyter notebook environment; some notebook implementations may not support magics correctly, in which case ipytest.run() and ipytest.clean() can be used directly.
Verify before relying
- Whether the 845-day dormancy affects compatibility with the latest Jupyter/IPython releases.
- Performance impact when running large test suites in notebooks with the assertion rewriter enabled globally.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (<4,>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — ipython, packaging, pytest |
| Maintenance | dormant — 845 days since the last release |
| First released | |
| Downloads | 77,508/month — #14,519 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: ipytest-0.14.2-py3-none-any.whl
Tags
More Testing packages
Pluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
virtualenvvirtualenv creates isolated Python environments…
permissive · top 100 on PyPI
coverageCoverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
pytest-asynciopytest-asyncio is a pytest plugin that enables…
permissive · top 1,000 on PyPI
pytest-json-ctrfA pytest plugin that generates test reports in…
permissive · top 1,000 on PyPI
nbvalA pytest plugin that treats Jupyter notebooks…
permissive · top 15,000 on PyPI
nbmakeA pytest plugin that executes Jupyter notebooks…
permissive · top 15,000 on PyPI
testbooktestbook lets you write unit tests for Jupyter…
permissive · top 15,000 on PyPI
ipykernelProvides the IPython kernel backend that powers…
permissive · top 1,000 on PyPI
pytest-runnerEnables running pytest tests through setup.py…
permissive · top 1,000 on PyPI
nbqaRuns standard Python linters and formatters…
permissive · top 15,000 on PyPI
pytest-djangopytest-django integrates Django with pytest,…
permissive · top 1,000 on PyPI
notebookJupyter Notebook is a web-based interactive…
permissive · top 1,000 on PyPI
ipywidgetsipywidgets provides interactive HTML widgets…
permissive · top 1,000 on PyPI
emr-notebooks-magicsProvides iPython magics for Amazon EMR…
permissive · top 5,000 on PyPI