A pytest plugin for testing Jupyter Notebooks
The purpose of the plugin is to ensure that changes to the python environment (e.g. updating packages), have not affected the outputs of the notebook. If the notebook has changed, this plugin can also regenerate the notebooks, saving the new outputs.
Recognise, collect, execute (optionally output) then diff input vs. output Jupyter Notebooks.
Provides clear and colorized diffs of the notebooks (using nbdime)
Regenerate failing notebooks.
A well defined API allows notebook regression tests to be run:
- Using the pytest test collection architecture.
- As a pytest fixtures (
- Using the
All stages are highly configurable via:
- The pytest command-line interface.
- The pytest configuration file.
- The notebook and cell level metadata.
Post-processor plugin entry-points, allow for customisable modifications of the notebook, including source code formatting with black
To install from Conda (recommended):
>> conda install -c conda-forge pytest-notebook
>> pip install pytest-notebook
To install the development version:
>> git clone https://github.com/chrisjsewell/pytest-notebook . >> cd pytest-notebook >> pip install -e . >> # pip install -e .[code_style,testing,docs] # install extras for more features
See the documentation at: http://pytest-notebook.readthedocs.io/
Contributions are very welcome.
The following will discover and run all unit test:
>> pip install -e .[testing] >> pytest -v
Coding Style Requirements
pytest-notebook[code_style] makes the pre-commit
package available, which will ensure these tests are passed by reformatting the code
and testing for lint errors before submitting a commit.
It can be setup by:
>> cd pytest-notebook >> pre-commit install
Optionally you can run
>> black . >> flake8 .
Editors like VS Code also have automatic code reformat utilities, which can adhere to this standard.
Distributed under the terms of the BSD-3 license,
pytest-notebook is free and open source software.
If you encounter any problems, please file an issue along with a detailed description.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size pytest_notebook-0.6.0-py3-none-any.whl (37.4 kB)||File type Wheel||Python version py3||Upload date||Hashes View hashes|
|Filename, size pytest-notebook-0.6.0.tar.gz (177.3 kB)||File type Source||Python version None||Upload date||Hashes View hashes|
Hashes for pytest_notebook-0.6.0-py3-none-any.whl