A Pytest plugin to enable Jupyter Notebook testing with Papermill
Project description
pytest-iovis
A plugin that lets you use pytest as a frontend to run and validate Jupyter Notebooks. Comes with some batteries included to get started.
$ pytest notebooks/ --verbose
================================= test session starts ==================================
platform linux -- Python 3.8.18, pytest-7.4.3, pluggy-1.3.0 -- /usr/bin/python3
rootdir: /home/user/Documents/git-repository
plugins: iovis-0.1.0
collected 5 items
notebooks/bar.ipynb::test_notebook_runs PASSED [1/5]
notebooks/baz.ipynb::test_notebook_runs PASSED [2/5]
notebooks/foo.ipynb::test_produces_expected_output PASSED [3/5]
notebooks/foo.ipynb::TestMetadata::test_extra_metadata_removed PASSED [4/5]
notebooks/foo.ipynb::TestMetadata::test_kernelspec_in_allowlist PASSED [5/5]
================================== 5 passed in 2.63s ===================================
Features
- Jupyter Notebooks are automatically discovered and run test functions that are user-configurable with directory
specific
conftest.pyfiles.
Miscellaneous features that help provide a batteries-included experience:
- A plugin provided default test function that uses papermill to run collected notebooks. This feature is optional
and can be enabled by installing the
[papermill]extra when installingpytest-iovis. - A
venvfixture which activates a test-specific virtual environment which has access to all packages from the host environment. Useful when running notebooks that targetipykernelthat may try to install packages.
Installation
You can install "pytest-iovis" with its default notebook runner via:
pip install 'pytest-iovis[papermill]'
If the bundled runner is not needed:
pip install 'pytest-iovis'
Note: Installing pytest-iovis does not install any kernels for running notebooks. Users should install notebook
kernels separately (e.g. pip install ipykernel).
Getting Started
Contributing
Please see CONTRIBUTING.md for instructions on how to contribute.
Issues
If you encounter any problems, please file an issue along with a detailed description.
Related Projects
-
testbook is a unit testing framework extension for testing code in Jupyter Notebooks. It enables the execution and unit testing of code without needing to modify the Jupyter Notebook itself, so that unit tests can be written using unittest, pytest, or another unit testing framework.
testbookandpytest-iovishave orthogonal goals, but happen to compliment each other fairly well. Example:from testbook import testbook @pytest.fixture() def tb(notebook_path: Path): with testbook(notebook_path, execute=True) as tb_obj: yield tb_obj def test_notebook(tb) -> None: func = tb.get("func") assert func(1, 2) == 3 def pytest_iovis_set_tests(): yield test_notebook
-
nbval is a pytest plugin that ensures that a notebook produces output matching the output stored in the notebook.
-
pytest-notebook plugin uses approval/snapshot testing to guard against regressions in notebook output.
Plugin Name
Iovis is the singular genitive case of Iuppiter.
Which is the Latin name of the Roman god Jupiter, from which the planet and Jupyter Notebooks take their namesake.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytest_iovis-0.1.0.tar.gz.
File metadata
- Download URL: pytest_iovis-0.1.0.tar.gz
- Upload date:
- Size: 23.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
67aefa579a1cdd5ab9ede1dd4076f95d61a8b813a28d7d3b27fc98fb0371ede1
|
|
| MD5 |
3582dce99febb77c46f9e7598f94e554
|
|
| BLAKE2b-256 |
7f01b24ae3e6f044675ee0f85d8c1ee04d7584e6c2131ce195de3b7e72b46419
|
Provenance
The following attestation bundles were made for pytest_iovis-0.1.0.tar.gz:
Publisher:
release.yml on kdestin/pytest-iovis
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytest_iovis-0.1.0.tar.gz -
Subject digest:
67aefa579a1cdd5ab9ede1dd4076f95d61a8b813a28d7d3b27fc98fb0371ede1 - Sigstore transparency entry: 147142974
- Sigstore integration time:
-
Permalink:
kdestin/pytest-iovis@8f1f550521831019e342b7250667d1b420bcf4ca -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/kdestin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8f1f550521831019e342b7250667d1b420bcf4ca -
Trigger Event:
push
-
Statement type:
File details
Details for the file pytest_iovis-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pytest_iovis-0.1.0-py3-none-any.whl
- Upload date:
- Size: 20.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70195ca95fa23123dee2ac7bd5fc66c253a3f03e1e7454679ed0373b6b2c2743
|
|
| MD5 |
b6fab3c9047c9cdbcb949e5847cdb665
|
|
| BLAKE2b-256 |
0952853614936a7d76a23da22a0448ebca39402b7c0c5f49abaffa7f38c1f54a
|
Provenance
The following attestation bundles were made for pytest_iovis-0.1.0-py3-none-any.whl:
Publisher:
release.yml on kdestin/pytest-iovis
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytest_iovis-0.1.0-py3-none-any.whl -
Subject digest:
70195ca95fa23123dee2ac7bd5fc66c253a3f03e1e7454679ed0373b6b2c2743 - Sigstore transparency entry: 147142975
- Sigstore integration time:
-
Permalink:
kdestin/pytest-iovis@8f1f550521831019e342b7250667d1b420bcf4ca -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/kdestin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8f1f550521831019e342b7250667d1b420bcf4ca -
Trigger Event:
push
-
Statement type: