testbook


Nametestbook JSON
Version 0.4.2 PyPI version JSON
download
home_pagehttps://github.com/nteract/testbook
SummaryA unit testing framework for Jupyter Notebooks
upload_time2021-06-02 19:59:55
maintainer
docs_urlNone
authornteract contributors
requires_python>=3.6
licenseBSD
keywords jupyter mapreduce nteract pipeline notebook
VCS
bugtrack_url
requirements nbformat nbclient
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![Build Status](https://github.com/nteract/testbook/workflows/CI/badge.svg)](https://github.com/nteract/testbook/actions)
[![image](https://codecov.io/github/nteract/testbook/coverage.svg?branch=master)](https://codecov.io/github/nteract/testbook?branch=master)
[![Documentation Status](https://readthedocs.org/projects/testbook/badge/?version=latest)](https://testbook.readthedocs.io/en/latest/?badge=latest)
[![PyPI](https://img.shields.io/pypi/v/testbook.svg)](https://pypi.org/project/testbook/)
[![Python 3.6](https://img.shields.io/badge/python-3.6-blue.svg)](https://www.python.org/downloads/release/python-360/)
[![Python 3.7](https://img.shields.io/badge/python-3.7-blue.svg)](https://www.python.org/downloads/release/python-370/)
[![Python 3.8](https://img.shields.io/badge/python-3.8-blue.svg)](https://www.python.org/downloads/release/python-380/)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/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:

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

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

```python
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`

```{code-block} bash
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:

```{code-block} bash
pip install testbook[dev]
```

## Documentation

See [readthedocs](https://testbook.readthedocs.io/en/latest/) for more in-depth details.

## Development Guide

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



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/nteract/testbook",
    "name": "testbook",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "jupyter mapreduce nteract pipeline notebook",
    "author": "nteract contributors",
    "author_email": "nteract@googlegroups.com",
    "download_url": "",
    "platform": "",
    "description": "[![Build Status](https://github.com/nteract/testbook/workflows/CI/badge.svg)](https://github.com/nteract/testbook/actions)\n[![image](https://codecov.io/github/nteract/testbook/coverage.svg?branch=master)](https://codecov.io/github/nteract/testbook?branch=master)\n[![Documentation Status](https://readthedocs.org/projects/testbook/badge/?version=latest)](https://testbook.readthedocs.io/en/latest/?badge=latest)\n[![PyPI](https://img.shields.io/pypi/v/testbook.svg)](https://pypi.org/project/testbook/)\n[![Python 3.6](https://img.shields.io/badge/python-3.6-blue.svg)](https://www.python.org/downloads/release/python-360/)\n[![Python 3.7](https://img.shields.io/badge/python-3.7-blue.svg)](https://www.python.org/downloads/release/python-370/)\n[![Python 3.8](https://img.shields.io/badge/python-3.8-blue.svg)](https://www.python.org/downloads/release/python-380/)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)\n\n# testbook\n\n**testbook** is a unit testing framework extension for testing code in Jupyter Notebooks.\n\nPrevious attempts at unit testing notebooks involved writing the tests in the notebook itself.\nHowever, testbook will allow for unit tests to be run against notebooks in separate test files,\nhence treating .ipynb files as .py files.\n\ntestbook helps you set up **conventional unit tests for your Jupyter Notebooks**.\n\nHere is an example of a unit test written using testbook\n\nConsider the following code cell in a Jupyter Notebook:\n\n```python\ndef func(a, b):\n   return a + b\n```\n\nYou would write a unit test using `testbook` in a Python file as follows:\n\n```python\nfrom testbook import testbook\n\n\n@testbook('/path/to/notebook.ipynb', execute=True)\ndef test_func(tb):\n   func = tb.get(\"func\")\n\n   assert func(1, 2) == 3\n```\n\n## Installing `testbook`\n\n```{code-block} bash\npip install testbook\n```\n\nNOTE: 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`\n\nAlternatively if you want all the same dev dependencies and the ipython kernel you can install these dependencies with:\n\n```{code-block} bash\npip install testbook[dev]\n```\n\n## Documentation\n\nSee [readthedocs](https://testbook.readthedocs.io/en/latest/) for more in-depth details.\n\n## Development Guide\n\nRead [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines on how to setup a local development environment and make code changes back to testbook.\n\n\n",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "A unit testing framework for Jupyter Notebooks",
    "version": "0.4.2",
    "split_keywords": [
        "jupyter",
        "mapreduce",
        "nteract",
        "pipeline",
        "notebook"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "cac91aad3fe0a2661e87064df13deceb",
                "sha256": "21e03818017d1315607e117c101cf4b5f5b6dcd5ead77eab65ac9508a281f644"
            },
            "downloads": -1,
            "filename": "testbook-0.4.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "cac91aad3fe0a2661e87064df13deceb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 11826,
            "upload_time": "2021-06-02T19:59:55",
            "upload_time_iso_8601": "2021-06-02T19:59:55.098805Z",
            "url": "https://files.pythonhosted.org/packages/a4/c7/c09d306c597411b0bebaa4c04daf4871bc2d4ee73f24c5c79bd6830afcb1/testbook-0.4.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2021-06-02 19:59:55",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "nteract",
    "github_project": "testbook",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "nbformat",
            "specs": [
                [
                    ">=",
                    "5.0.4"
                ]
            ]
        },
        {
            "name": "nbclient",
            "specs": [
                [
                    ">=",
                    "0.4.0"
                ]
            ]
        }
    ],
    "tox": true,
    "lcname": "testbook"
}
        
Elapsed time: 0.02369s