Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

🧪 📗 Unit test your Jupyter Notebooks the right way

License

NotificationsYou must be signed in to change notification settings

nteract/testbook

Build StatusimageDocumentation StatusimageimageimageCode 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 upconventional 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 Notebookexample_notebook.ipynb:

deffunc(a,b):returna+b

You would write a unit test usingtestbook in a Python fileexample_test.py as follows:

# example_test.pyfromtestbookimporttestbook@testbook('/path/to/example_notebook.ipynb',execute=True)deftest_func(tb):func=tb.get("func")assertfunc(1,2)==3

Thenpytest can be used to run the test:

pytest example_test.py

Installingtestbook

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 withpip 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

Seereadthedocs for more in-depth details.

Development Guide

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

About

🧪 📗 Unit test your Jupyter Notebooks the right way

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors16


[8]ページ先頭

©2009-2026 Movatter.jp