Skip to main content

A pytest plugin for testing Jupyter Notebooks

Project description

pytest-notebook

Build Status Coverage Status Docs status PyPI Conda Code style: black

A pytest plugin for regression testing and regenerating Jupyter Notebooks.

Example Test


Features

  • Recognise, collect, execute (optionally output) then diff input vs. output Jupyter Notebooks.

  • Provides clear and colorized diffs of the notebooks (using nbdime)

  • 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 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 -e .
>> # pip install -e .[code_style,testing,docs] # install extras for more features

Usage

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

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest-notebook-0.3.0.tar.gz (25.3 kB view details)

Uploaded Source

Built Distribution

pytest_notebook-0.3.0-py3-none-any.whl (20.4 kB view details)

Uploaded Python 3

File details

Details for the file pytest-notebook-0.3.0.tar.gz.

File metadata

  • Download URL: pytest-notebook-0.3.0.tar.gz
  • Upload date:
  • Size: 25.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.6.7

File hashes

Hashes for pytest-notebook-0.3.0.tar.gz
Algorithm Hash digest
SHA256 c3ca60c4b4f3a0a5ea9654fa850e28e9a1339e0d41d5ce8b6a793c00f37707b8
MD5 7287fe80b9d3f58826b11efec8593ecc
BLAKE2b-256 c66973509233799053732e80c376e35904e4d9f6948453734577909b131c931c

See more details on using hashes here.

Provenance

File details

Details for the file pytest_notebook-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: pytest_notebook-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 20.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.6.7

File hashes

Hashes for pytest_notebook-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 26e93446ecd366513d4e8cce5dedce7e09d8e59ae864bddd2d71a7bd2b8a5ed1
MD5 ad404c20b40db0de5c40b0678a510cbf
BLAKE2b-256 afe67697d21e0360ed0f186f1d8adfc6d9ffcc6699ab20b20a6da9ea5149fb96

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page