{"id":13607749,"url":"https://github.com/nteract/testbook","last_synced_at":"2025-04-11T22:29:47.457Z","repository":{"id":39572753,"uuid":"243350564","full_name":"nteract/testbook","owner":"nteract","description":"🧪 📗  Unit test your Jupyter Notebooks the right way","archived":false,"fork":false,"pushed_at":"2024-08-25T01:24:05.000Z","size":165,"stargazers_count":426,"open_issues_count":46,"forks_count":38,"subscribers_count":15,"default_branch":"main","last_synced_at":"2025-04-04T05:40:37.379Z","etag":null,"topics":["jupyter-notebook","nteract","pytest","python","testbook","unit-testing"],"latest_commit_sha":null,"homepage":"https://testbook.readthedocs.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nteract.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-26T19:43:22.000Z","updated_at":"2025-04-02T19:53:02.000Z","dependencies_parsed_at":"2024-08-25T02:31:56.300Z","dependency_job_id":"5e2c2129-df80-4751-9fc0-9dee11a640d0","html_url":"https://github.com/nteract/testbook","commit_stats":{"total_commits":122,"total_committers":17,"mean_commits":7.176470588235294,"dds":0.3278688524590164,"last_synced_commit":"9d48dbb18d4b3620fcd962929e3b404af4afeea6"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nteract%2Ftestbook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nteract%2Ftestbook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nteract%2Ftestbook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nteract%2Ftestbook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nteract","download_url":"https://codeload.github.com/nteract/testbook/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248489307,"owners_count":21112545,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["jupyter-notebook","nteract","pytest","python","testbook","unit-testing"],"created_at":"2024-08-01T19:01:21.268Z","updated_at":"2025-04-11T22:29:47.436Z","avatar_url":"https://github.com/nteract.png","language":"Python","readme":"[![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[![image](https://img.shields.io/pypi/v/testbook.svg)](https://pypi.python.org/pypi/testbook)\n[![image](https://img.shields.io/pypi/l/testbook.svg)](https://github.com/astral-sh/testbook/blob/main/LICENSE)\n[![image](https://img.shields.io/pypi/pyversions/testbook.svg)](https://pypi.python.org/pypi/testbook)\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 `example_notebook.ipynb`:\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 `example_test.py` as follows:\n\n```python\n# example_test.py\nfrom testbook import testbook\n\n\n@testbook('/path/to/example_notebook.ipynb', execute=True)\ndef test_func(tb):\n   func = tb.get(\"func\")\n\n   assert func(1, 2) == 3\n```\n\nThen [pytest](https://github.com/pytest-dev/pytest) can be used to run the test:\n\n```{code-block} bash\npytest example_test.py\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","funding_links":[],"categories":["Python","Notebook Tools","Jupyter-Notebook工具","Testing Frameworks"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnteract%2Ftestbook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnteract%2Ftestbook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnteract%2Ftestbook/lists"}