Skip to main content
Warning: You are using the test version of PyPI. This is a pre-production deployment of Warehouse. Changes made here affect the production instance of TestPyPI (
Help us improve Python packaging - Donate today!

Use pytest's runner to discover and execute tests as cells of IPython notebooks

Project Description

Plugin for pytest to run IPython notebooks as unit tests

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

Run py.test to execute them:


See the examples/ folder or a preview on nbviewer.


  • 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
  • IPython notebook kernel is restarted after each test


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


$ pip install pytest-ipynb


Andrea Zonca

Release History

This version
History Node


Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting