Metadata-Version: 2.4
Name: pytest-jupyter
Version: 0.10.1
Summary: A pytest plugin for testing Jupyter libraries and extensions.
Project-URL: Homepage, http://jupyter.org
Project-URL: Funding, https://numfocus.org/donate
Project-URL: Source, https://github.com/jupyter-server/pytest-jupyter
Project-URL: Tracker, https://github.com/jupyter-server/pytest-jupyter/issues
Author-email: Jupyter Development Team <jupyter@googlegroups.com>
License: # Licensing terms
        
        This project is licensed under the terms of the Modified BSD License
        (also known as New or Revised or 3-Clause BSD), as follows:
        
        - Copyright (c) 2020-, Jupyter Development Team
        
        All rights reserved.
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        Redistributions of source code must retain the above copyright notice, this
        list of conditions and the following disclaimer.
        
        Redistributions in binary form must reproduce the above copyright notice, this
        list of conditions and the following disclaimer in the documentation and/or
        other materials provided with the distribution.
        
        Neither the name of the Jupyter Development Team nor the names of its
        contributors may be used to endorse or promote products derived from this
        software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
        ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
        WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        
        ## About the Jupyter Development Team
        
        The Jupyter Development Team is the set of all contributors to the Jupyter project.
        This includes all of the Jupyter subprojects.
        
        The core team that coordinates development on GitHub can be found here:
        https://github.com/jupyter/.
        
        ## Our Copyright Policy
        
        Jupyter uses a shared copyright model. Each contributor maintains copyright
        over their contributions to Jupyter. But, it is important to note that these
        contributions are typically only changes to the repositories. Thus, the Jupyter
        source code, in its entirety is not the copyright of any single person or
        institution.  Instead, it is the collective copyright of the entire Jupyter
        Development Team.  If individual contributors want to maintain a record of what
        changes/contributions they have specific copyright on, they should indicate
        their copyright in the commit message of the change, when they commit the
        change to one of the Jupyter repositories.
        
        With this in mind, the following banner should be used in any source code file
        to indicate the copyright and license terms:
        
            # Copyright (c) Jupyter Development Team.
            # Distributed under the terms of the Modified BSD License.
        
        
        Pytest Tornasync File License
        =============================
        
        The pytest_jupyter/pytest_tornasync.py was originally licensed as:
        
        The MIT License (MIT)
        
        Copyright (c) 2016 eukaryote
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: Jupyter,pytest
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: Jupyter
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.8
Requires-Dist: jupyter-core>=5.7
Requires-Dist: pytest>=7.0
Provides-Extra: client
Requires-Dist: ipykernel>=6.14; extra == 'client'
Requires-Dist: jupyter-client>=7.4.0; extra == 'client'
Requires-Dist: nbformat>=5.3; extra == 'client'
Provides-Extra: docs
Requires-Dist: myst-parser; extra == 'docs'
Requires-Dist: pydata-sphinx-theme; extra == 'docs'
Requires-Dist: sphinx; extra == 'docs'
Requires-Dist: sphinxcontrib-spelling; extra == 'docs'
Provides-Extra: server
Requires-Dist: ipykernel>=6.14; extra == 'server'
Requires-Dist: jupyter-client>=7.4.0; extra == 'server'
Requires-Dist: jupyter-server>=1.21; extra == 'server'
Requires-Dist: nbformat>=5.3; extra == 'server'
Provides-Extra: test
Requires-Dist: pytest-timeout; extra == 'test'
Description-Content-Type: text/markdown

# pytest-jupyter

A set of pytest plugins for Jupyter libraries and extensions.

[![Build Status](https://github.com/jupyter-server/pytest-jupyter/actions/workflows/test.yml/badge.svg?query=branch%3Amain++)](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": "<desired_kernel_name"
    }
}
```

All fixtures inside the plugin (e.g. jupyter_server) will be available to all of your project's unit tests. You can use a fixtures by passing it as an argument to your unit test function:

```python
async def test_jupyter_server_api(jp_fetch):
    # Send request to a temporary Jupyter Server Web Application
    response = await jp_fetch("api/spec.yml")

    # Confirm that the request is successful.
    assert response.code == 200
```

You can list the fixtures for a given plugin using the `--fixtures` argument from the pytest command line interface:

```bash
pytest --fixtures -p pytest_jupyter.jupyter_server
```

or by calling the `pytest --fixtures` where the plugin is listed in the `pytest_plugins` variable of a given test directory.
