https://github.com/jupyter-server/pytest-jupyter
A pytest plugin for testing Jupyter core libraries and extensions.
https://github.com/jupyter-server/pytest-jupyter
jupyter pytest pytest-plugin
Last synced: 7 months ago
JSON representation
A pytest plugin for testing Jupyter core libraries and extensions.
- Host: GitHub
- URL: https://github.com/jupyter-server/pytest-jupyter
- Owner: jupyter-server
- License: other
- Created: 2020-10-29T16:12:52.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2025-04-10T09:35:16.000Z (8 months ago)
- Last Synced: 2025-04-10T10:50:18.343Z (8 months ago)
- Topics: jupyter, pytest, pytest-plugin
- Language: Python
- Homepage: https://pytest-jupyter.readthedocs.io/
- Size: 179 KB
- Stars: 14
- Watchers: 8
- Forks: 15
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# pytest-jupyter
A set of pytest plugins for Jupyter libraries and extensions.
[](https://github.com/jupyter-server/pytest-jupyter/actions/workflows/test.yml/badge.svg?query=branch%3Amain++)
## Basic Usage
First, install `pytest-jupyter` from PyPI using pip:
```bash
pip install pytest-jupyter
```
This installs the basic pytest-jupyter package that includes fixture definitions for the various Jupyter-based pytest plugins.
To use one of these plugins, you'll also need to install their dependencies. This requires a second `pip install` call. For example, if you'd like to use the `jupyter_server` plugin, you'll need to call:
```bash
pip install "pytest-jupyter[server]"
```
This *should* install everything you need for the plugin to work.
To use a plugin, add it to the `pytest_plugins` list in the `conftest.py` of your project's root test directory.
```python
# inside the conftest.py
pytest_plugins = ["pytest_jupyter.jupyter_server"]
```
This library includes an `echo_kernel`, which is useful to speed up testing.
You must have either `"pytest-jupyter[server]"` or `"pytest-jupyter[client]"`
installed to use the echo kernel.
The `pytest_jupyter.jupyter_client` plugin provides an installed
`echo_kernel_spec` as a fixture, and a `start_kernel` fixture
that provides a factory function that starts a kernel using the `echo` kernel
by default.
*Note*: The server plugin also includes the client plugin, so you can use both
sets of fixtures with `"pytest_jupyter.jupyter_server"`. Both the `client`
and `server` plugins also include the core fixtures.
*Note*: The client and server plugins use `pytest-tornasync` for async
test suite running. It may not compatible with `pytest-asyncio`, meaning
that all fixtures must be synchronous. You can use the `asyncio_loop` fixture
and run `asyncio_loop.run_until_complete` against an async function in your
fixtures if needed.
The server fixures use the echo kernel by default. To override this behavior,
override the `jp_server_config` fixture and add the following config:
```json
{
"MultiKernelManager": {
"default_kernel_name": "