zonca / pytest-ipynb

Plugin for pytest to run IPython notebook cells as unit tests

Home Page:http://zonca.github.io/2014/09/unit-tests-ipython-notebook.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pytest-ipynb

THE PROJECT IS NOT MAINTAINED ANYMORE Anyone is welcome to fork and update the software using the same name without the need to ask or even notify me.

Plugin for pytest to run IPython notebooks as unit tests, relies on runipy to interface with the Notebook.

Define unit tests in IPython notebook cells (see example on nbviewer):

Example notebook

Run py.test to execute them:

Example output

Example

See the examples/ folder or a preview on nbviewer.

Features

  • Discover files named test*.ipynb
  • Run each cell of the notebook as a unit test (just use assert)
  • First line of each cell is the test name, either as docstring, comment or function name
  • A cell named fixture* or setup* is run before each of the following unit tests as a fixture
  • Add SKIPCI to a cell description to skip the test on Travis-CI (checks if the CI environment variable is defined)
  • IPython notebook kernel is restarted after each test
  • Each notebook is executed in the folder where the .ipynb file is located

Requirements

  • Python 2.7+, Python 3.2+
  • pytest
  • IPython Notebook 2.0+

Install

$ pip install pytest-ipynb

Author

Andrea Zonca

Credits

About

Plugin for pytest to run IPython notebook cells as unit tests

http://zonca.github.io/2014/09/unit-tests-ipython-notebook.html

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Python 100.0%