Skip to main content

Udemy clone of nteract/testbook, a unit testing framework for Jupyter Notebooks

Project description

Build Status image Documentation Status PyPI Python 3.6 Python 3.7 Python 3.8 Python 3.9 Code style: black

testbook

testbook is a unit testing framework extension for testing code in Jupyter Notebooks.

Previous attempts at unit testing notebooks involved writing the tests in the notebook itself. However, testbook will allow for unit tests to be run against notebooks in separate test files, hence treating .ipynb files as .py files.

testbook helps you set up conventional unit tests for your Jupyter Notebooks.

Here is an example of a unit test written using testbook

Consider the following code cell in a Jupyter Notebook:

def func(a, b):
   return a + b

You would write a unit test using testbook in a Python file as follows:

from testbook import testbook


@testbook('/path/to/notebook.ipynb', execute=True)
def test_func(tb):
   func = tb.get("func")

   assert func(1, 2) == 3

Installing testbook

pip install testbook

NOTE: This does not install any kernels for running your notebooks. You'll need to install in the same way you do for running the notebooks normally. Usually this is done with pip install ipykernel

Alternatively if you want all the same dev dependencies and the ipython kernel you can install these dependencies with:

pip install testbook[dev]

Documentation

See readthedocs for more in-depth details.

Development Guide

Read CONTRIBUTING.md for guidelines on how to setup a local development environment and make code changes back to testbook.

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

ud-testbook-0.0.4.tar.gz (29.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ud_testbook-0.0.4-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file ud-testbook-0.0.4.tar.gz.

File metadata

  • Download URL: ud-testbook-0.0.4.tar.gz
  • Upload date:
  • Size: 29.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for ud-testbook-0.0.4.tar.gz
Algorithm Hash digest
SHA256 9d256dd4f03804aae45e76d6e23d3792993330b8b4c94ad86eab123caf877a35
MD5 88223db62104b9c433d80e2d3be0546d
BLAKE2b-256 29bdf617827e1a08c2489ffdbb6c0bc35b4aa0a9bc7efe6d5fa6ae20ff476a2b

See more details on using hashes here.

File details

Details for the file ud_testbook-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: ud_testbook-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 12.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for ud_testbook-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 29d6e2ad3f70762f2b1c73d3457c4820d63c62e86d41c4f1ce094f2cb6572935
MD5 73d87b6a47dbdad71f1cd1b84ba83a30
BLAKE2b-256 b5f1d6d3184146b5e634e98ce263cefa548e6ef313308700388ac61cde4bb7fb

See more details on using hashes here.

Supported by

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