Name | pytest-ipynb2 JSON |
Version |
0.2.1
JSON |
| download |
home_page | None |
Summary | Pytest plugin to run tests in Jupyter Notebooks |
upload_time | 2025-02-19 15:23:17 |
maintainer | None |
docs_url | None |
author | Mike Foster |
requires_python | >=3.9 |
license | MIT |
keywords |
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# pytest-ipynb2
A pytest plugin to run tests in Jupyter Notebooks.
Designed to play nicely with [chmp/ipytest](https://github.com/chmp/ipytest).
## Why?
My use case is so that I can teach my son to code and use notebooks to do that but still have the tests show up in vscode test explorer.
We also like to have all our tests run in a github workflow - and this makes that simple too.
## Usage
Usage is very simple:
1. Install from pypi (e.g. with pip):
```sh
pip install pytest-ipynb2
```
1. Enable by adding to the default options in `pyproject.toml`:
```toml
[tool.pytest.ini_options]
addopts = [
"-p pytest_ipynb2.plugin",
]
```
1. That's it! pytest will now collect and execute any tests in jupyter notebooks when run form the command line or IDE.
## Test identification
I'm assuming you also want to run your tests inside your notebooks ... so simply use the `%%ipytest` magic in a cell and pytest will collect any tests based on the usual naming and identification rules.
> **Note:** tests will *only* be identified in cells which use the `%%ipytest` magic
## Documentation
For more details see the [docs](https://musicalninjadad.github.io/pytest-ipynb2)
## Features
- Enables pytest to collect and execute tests stored within jupyter notebooks
- Provides meaningful test logs identifying the notebook, cell and test function
- Handles tests with fixtures and parametrization
- Executes *all cells above* the test cell before running the tests in that cell.
>WARNING: this means that if any previous cells have side-effects they will occur on test collection, just as they would if included in a pytest test module.
## Known limitations & To-Dos
This is an early version. The following things are still on my to-do list:
- Handling tests grouped into classes [#22](https://github.com/MusicalNinjaDad/pytest-ipynb2/issues/22) (might work - I've not checked yet)
- Assertion re-writing. Failed tests don't yet give the expected quality of pytest output about the failure [#20](https://github.com/MusicalNinjaDad/pytest-ipynb2/issues/20) (Workaround - re-run the test using ipytest inside the notebook)
- v1.0.0 will include dedicated commandline options rather than requiring you to specify the plugin [#12](https://github.com/MusicalNinjaDad/pytest-ipynb2/issues/12)
- This won't play nicely with other magics or direct calls to ipytest functions yet [#23](https://github.com/MusicalNinjaDad/pytest-ipynb2/issues/23)
Raw data
{
"_id": null,
"home_page": null,
"name": "pytest-ipynb2",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": null,
"author": "Mike Foster",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/0b/6a/3894169b0cbc8b9d433cd44d98ff5dfe8d85714f961c887b4084ba60a29c/pytest_ipynb2-0.2.1.tar.gz",
"platform": null,
"description": "# pytest-ipynb2\n\nA pytest plugin to run tests in Jupyter Notebooks.\n\nDesigned to play nicely with [chmp/ipytest](https://github.com/chmp/ipytest).\n\n## Why?\n\nMy use case is so that I can teach my son to code and use notebooks to do that but still have the tests show up in vscode test explorer.\n\nWe also like to have all our tests run in a github workflow - and this makes that simple too.\n\n## Usage\n\nUsage is very simple:\n\n1. Install from pypi (e.g. with pip):\n\n ```sh\n pip install pytest-ipynb2\n ```\n\n1. Enable by adding to the default options in `pyproject.toml`:\n\n ```toml\n [tool.pytest.ini_options]\n addopts = [\n \"-p pytest_ipynb2.plugin\",\n ]\n ```\n\n1. That's it! pytest will now collect and execute any tests in jupyter notebooks when run form the command line or IDE.\n\n## Test identification\n\nI'm assuming you also want to run your tests inside your notebooks ... so simply use the `%%ipytest` magic in a cell and pytest will collect any tests based on the usual naming and identification rules.\n\n> **Note:** tests will *only* be identified in cells which use the `%%ipytest` magic\n\n## Documentation\n\nFor more details see the [docs](https://musicalninjadad.github.io/pytest-ipynb2)\n\n## Features\n\n- Enables pytest to collect and execute tests stored within jupyter notebooks\n- Provides meaningful test logs identifying the notebook, cell and test function\n- Handles tests with fixtures and parametrization\n- Executes *all cells above* the test cell before running the tests in that cell.\n\n >WARNING: this means that if any previous cells have side-effects they will occur on test collection, just as they would if included in a pytest test module.\n\n## Known limitations & To-Dos\n\nThis is an early version. The following things are still on my to-do list:\n\n- Handling tests grouped into classes [#22](https://github.com/MusicalNinjaDad/pytest-ipynb2/issues/22) (might work - I've not checked yet)\n- Assertion re-writing. Failed tests don't yet give the expected quality of pytest output about the failure [#20](https://github.com/MusicalNinjaDad/pytest-ipynb2/issues/20) (Workaround - re-run the test using ipytest inside the notebook)\n- v1.0.0 will include dedicated commandline options rather than requiring you to specify the plugin [#12](https://github.com/MusicalNinjaDad/pytest-ipynb2/issues/12)\n- This won't play nicely with other magics or direct calls to ipytest functions yet [#23](https://github.com/MusicalNinjaDad/pytest-ipynb2/issues/23)\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Pytest plugin to run tests in Jupyter Notebooks",
"version": "0.2.1",
"project_urls": {
"Changelog": "https://github.com/MusicalNinjaDad/pytest-ipynb2/blob/main/CHANGELOG.md",
"Documentation": "https://musicalninjadad.github.io/pytest-ipynb2",
"Issues": "https://github.com/MusicalNinjaDad/pytest-ipynb2/issues",
"Repository": "https://github.com/MusicalNinjaDad/pytest-ipynb2"
},
"split_keywords": [],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "77bb250c883fb53461549ccd8351dcf16b0cc230ab9f2ae40f7b5bc1f614af6b",
"md5": "83b5ae2fe7bd85ef02d4c81f75999fdf",
"sha256": "dbe46109aa3358be05c3d35f475c23732cc5ad52cc24ba5fa35b68bf4dd803d3"
},
"downloads": -1,
"filename": "pytest_ipynb2-0.2.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "83b5ae2fe7bd85ef02d4c81f75999fdf",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 19011,
"upload_time": "2025-02-19T15:23:16",
"upload_time_iso_8601": "2025-02-19T15:23:16.445443Z",
"url": "https://files.pythonhosted.org/packages/77/bb/250c883fb53461549ccd8351dcf16b0cc230ab9f2ae40f7b5bc1f614af6b/pytest_ipynb2-0.2.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "0b6a3894169b0cbc8b9d433cd44d98ff5dfe8d85714f961c887b4084ba60a29c",
"md5": "657ec8a1483d9799f4ee71dcba4e3448",
"sha256": "bb4d5f731901b749d353211879554ba492cb1feb53e01c39959ed8fb8f949e05"
},
"downloads": -1,
"filename": "pytest_ipynb2-0.2.1.tar.gz",
"has_sig": false,
"md5_digest": "657ec8a1483d9799f4ee71dcba4e3448",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 16354,
"upload_time": "2025-02-19T15:23:17",
"upload_time_iso_8601": "2025-02-19T15:23:17.697932Z",
"url": "https://files.pythonhosted.org/packages/0b/6a/3894169b0cbc8b9d433cd44d98ff5dfe8d85714f961c887b4084ba60a29c/pytest_ipynb2-0.2.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-19 15:23:17",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "MusicalNinjaDad",
"github_project": "pytest-ipynb2",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "pytest-ipynb2"
}