Registry / testing / ipytest

ipytest

JSON →
library0.14.2pypypi✓ verified 85d ago

ipytest provides utilities for running unit tests inside IPython notebooks, allowing inline test definition and execution with pytest. Current version: 0.14.2, requires Python >=3.8 and <4. Releases are infrequent.

pip install ipytest
INSTALL
IMPORT
SIG · IPYTEST
I
ipytest
testingpythonv0.14.2
Install
5.2s avg
Import
394ms
Disk
77MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.14.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.418s · 84.2MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 5.2s · import 0.370s · 85MB
77MB installed
● package 77MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ipytest
import ipytest

After importing ipytest, call autoconfig() to configure pytest for notebook. Define tests as functions starting with 'test_', then run them with ipytest.run().

import ipytest import pytest ipytest.autoconfig() def test_example(): assert 1 + 1 == 2 ipytest.run()
Debug
Known issues
gotchaipytest must be imported before any test functions are defined, otherwise tests may not be discovered.
fix
Always import ipytest at the top of your notebook cell before defining test functions.
affects: all
breakingVersion 0.14 changed the autoconfig() signature; now it accepts no arguments and configures automatically. Previously, you had to pass a conftest path.
fix
Use ipytest.autoconfig() without arguments. Do not pass config paths.
affects: >=0.14.0
deprecatedThe ipytest.magics module (e.g., %%run_tests magic) is deprecated in favor of plain Python function calls.
fix
Use ipytest.run() instead of the cell magic.
affects: >=0.14.0
gotchaTests must be defined inside an IPython notebook cell; ipytest does not work if called from a separate .py file via import.
fix
Define tests directly in a notebook cell and execute that cell to register them.
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'ipytest'
ipytest is not installed in the current Python environment.
fix
Run `pip install ipytest` and ensure you are using the same kernel as the installation.
UsageError: Cell magic `%%run_tests` not found.
The deprecated magic module is not loaded; you may be using a version that removed it.
fix
Use ipytest.run() instead of the cell magic. Or load the magics with `%load_ext ipytest.magics` (deprecated).
TypeError: autoconfig() takes 0 positional arguments but 1 was given
You are passing arguments to autoconfig() in version 0.14+, which no longer accepts them.
fix
Remove arguments: just call `ipytest.autoconfig()` without any parameters.
ValueError: No tests found
ipytest.run() could not discover any test functions. Ensure test functions are named with 'test_' prefix and defined before calling run().
fix
Check that your test function names start with 'test_' and that you have defined them before invoking ipytest.run().
Upgrade
Version history
0.14.2latest on PyPI · released Apr 21, 2024
Audit
Dependencies
pytestrequiredRequired for running tests; ipytest is an extension of pytest.
ipythonrequiredRequired for notebook environment; ipytest is designed for IPython.
Agent activity
9 hits · last 30 days
node
8
Resources
ipytest — pip install ipytest · libregistry