skillfed

ipytest

Unit tests in IPython notebooks

ipytest v0.14.2 77.5K downloads/30d#14,519 on PyPI
Permissive license MIT DORMANT released

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 ipytest

uv

uv add ipytest

poetry

poetry add ipytest

Installing 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

Development Status :: 4 - BetaIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: Testing

Tags

pytest in jupyter notebooksunit testing jupyteripython notebook testingrun tests in notebookjupyter test runnernotebook pytest integrationinteractive test execution
jupyter-integrationinteractive-testing

More Testing packages