All Projects → chrisjsewell → pytest-notebook

chrisjsewell / pytest-notebook

Licence: BSD-3-Clause license
A pytest plugin for regression testing and regenerating Jupyter Notebooks

Programming Languages

Jupyter Notebook
11667 projects
python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to pytest-notebook

importnb
notebook files as source
Stars: ✭ 47 (+34.29%)
Mutual labels:  jupyter, notebook, pytest
pytest-elk-reporter
A plugin to send pytest test results to ELK stack
Stars: ✭ 17 (-51.43%)
Mutual labels:  pytest, pytest-plugin
pytest-datafixtures
Data fixtures for pytest made simple
Stars: ✭ 24 (-31.43%)
Mutual labels:  pytest, pytest-plugin
ipychart
The power of Chart.js with Python
Stars: ✭ 48 (+37.14%)
Mutual labels:  jupyter, notebook
2021 course dev-rougier
NumFocus Academy - Matplotlib (beginner)
Stars: ✭ 54 (+54.29%)
Mutual labels:  jupyter, notebook
mercury
Mercury - data visualize and discovery with Javascript, such as apache zeppelin and jupyter
Stars: ✭ 29 (-17.14%)
Mutual labels:  jupyter, notebook
pytest-test-groups
A Pytest plugin that gives you a way to split your tests into groups of a specific size
Stars: ✭ 37 (+5.71%)
Mutual labels:  pytest, pytest-plugin
pytest-subprocess
Pytest plugin to fake subprocess.
Stars: ✭ 83 (+137.14%)
Mutual labels:  pytest, pytest-plugin
python ml tutorial
A complete tutorial in python for Data Analysis and Machine Learning
Stars: ✭ 118 (+237.14%)
Mutual labels:  jupyter, notebook
Hello-Kaggle-Guide-KOR
Kaggle을 처음 접하는 사람들을 위한 문서
Stars: ✭ 140 (+300%)
Mutual labels:  jupyter, notebook
biojupies
Automated generation of tailored bioinformatics Jupyter Notebooks via a user interface.
Stars: ✭ 96 (+174.29%)
Mutual labels:  jupyter, notebook
pytest-mock-server
Mock server plugin for pytest
Stars: ✭ 19 (-45.71%)
Mutual labels:  pytest, pytest-plugin
pytest-csv
CSV reporter for pytest.
Stars: ✭ 16 (-54.29%)
Mutual labels:  pytest, pytest-plugin
covdefaults
A coverage plugin to provide sensible default settings
Stars: ✭ 38 (+8.57%)
Mutual labels:  coverage, pytest
ipython pytest
Pytest magic for IPython notebooks
Stars: ✭ 33 (-5.71%)
Mutual labels:  jupyter, pytest
observable-jupyter
Embed visualizations and code from Observable notebooks in Jupyter
Stars: ✭ 27 (-22.86%)
Mutual labels:  jupyter, notebook
colab-badge-action
GitHub Action that generates "Open In Colab" Badges for you
Stars: ✭ 15 (-57.14%)
Mutual labels:  jupyter, notebook
pytest-docker-tools
Opionated helpers for creating py.test fixtures for Docker integration and smoke testing environments
Stars: ✭ 61 (+74.29%)
Mutual labels:  pytest, pytest-plugin
itikz
Cell and line magic for PGF/TikZ-to-SVG rendering in Jupyter notebooks
Stars: ✭ 55 (+57.14%)
Mutual labels:  jupyter, ipython-notebook
pytest-pipeline
Pytest plugin for functional testing of data analysis pipelines
Stars: ✭ 19 (-45.71%)
Mutual labels:  pytest, pytest-plugin

pytest-notebook

CI Coverage RTD PyPI Conda Code style: black

A pytest plugin for regression testing and regenerating Jupyter Notebooks.

Example Test


Purpose

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.

Features

  • 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.

  • Integration with coverage and pytest_cov.

  • A well defined API allows notebook regression tests to be run:

    1. Using the pytest test collection architecture.
    2. As a pytest fixtures (nb_regression.check(filename)).
    3. Using the pytest_notebook python package.
  • All stages are highly configurable via:

    1. The pytest command-line interface.
    2. The pytest configuration file.
    3. The notebook and cell level metadata.
  • Post-processor plugin entry-points, allow for customisable modifications of the notebook, including source code formatting with black

Configuration Examples

Installation

To install from Conda (recommended):

>> conda install -c conda-forge pytest-notebook

To install via pip from PyPI:

>> pip install pytest-notebook

To install the development version:

>> git clone https://github.com/chrisjsewell/pytest-notebook .
>> cd pytest-notebook
>> pip install --upgrade pip
>> pip install -e .
>> # pip install -e .[code_style,testing,docs] # install extras for more features

Usage

See the documentation at: http://pytest-notebook.readthedocs.io/

If you want to test some sample notebooks, add the --nb-test-files flag:

>> git clone https://github.com/chrisjsewell/pytest-notebook
>> cd pytest-notebook/samples
>> pip install pytest ipykernel pytest-notebook
>> pytest --nb-test-files *.ipynb

You should see success.ipynb passed the test and fail.ipynb failed the test.

You can regenerate the outputs of fail.ipynb with the --nb-force-regen flag:

>> pytest --nb-test-files --nb-force-regen *.ipynb

Contributing

Contributions are very welcome.

The following will discover and run all unit test:

>> pip install -e .[testing]
>> pytest -v

Coding Style Requirements

The code style is tested using flake8, with the configuration set in .flake8, and code should be formatted with black.

Installing with 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 and flake8 separately:

>> black .
>> flake8 .

Editors like VS Code also have automatic code reformat utilities, which can adhere to this standard.

License

Distributed under the terms of the BSD-3 license, pytest-notebook is free and open source software.

Issues

If you encounter any problems, please file an issue along with a detailed description.

Acknowledgements

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].