• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

chrisjsewell/pytest-notebook: A pytest plugin for regression testing and regener ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

chrisjsewell/pytest-notebook

开源软件地址:

https://github.com/chrisjsewell/pytest-notebook

开源编程语言:

Jupyter Notebook 55.0%

开源软件介绍:

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




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap