Name | pytest-jupyterhub JSON |
Version |
0.0.1.dev0
JSON |
| download |
home_page | |
Summary | A reusable JupyterHub pytest plugin |
upload_time | 2023-04-13 09:53:27 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.8 |
license | BSD 3-Clause License Copyright (c) 2022, JupyterHub Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. 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. 3. Neither the name of the copyright holder 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 HOLDER 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. |
keywords |
jupyterhub
plugin
pytest
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Reusable JupyterHub Pytest Plugin
## Description
This is a reusable pytest plugin for testing JupyterHub's components
**JupyterHub** is a modular and extensible project, with components, like the **proxy**, **authenticator** and **spawner**, that can be easily replaced with alternate implementations. Testing the functionality of these components against JupyterHub is important and it requires various hub setups that can sometimes become complicated.
Each of these hub components and the hub itself define their own testing infrastructure, building everything from the ground up using the **pytest** framework. And some of this complex work is either repetitive across JupyterHub sub-projects, or under-specified for some of them. This has sparked a need to abstract these common parts into a separate testing framework.
The goal is to provide importable testing utilities to make it easier for contributors to write tests for the various hub components.
This will involve creating and using **fixtures** and **mocks**.
A **Fixture** is a function that is used to prepare and clean up the environment for a test function. Fixtures can be used to set up test data, test environment, and other resources that are needed by test functions.
For more information on Fixtures, check out this [pytest documentation](https://docs.pytest.org/en/latest/explanation/fixtures.html) on fixtures.
A **Mock** is an object that simulates the behavior of another object such as a class or function. They are used to simulate the behavior of real objects for testing purposes.
For more information on Mocks, check out this [unittest documentation](https://docs.python.org/3/library/unittest.mock.html) on the mock module.
**Example:**
The [init_db](https://github.com/jupyterhub/jupyterhub/blob/336d7cfcfaf74087e4ee467d5e3d3bec0c25c3d0/jupyterhub/app.py#L1804) function in JupyterHub's `app` module initializes a connection to a database using SQLAlchemy's ORM (Object-Relational Mapper).
However, the mock [init_db](https://github.com/jupyterhub/jupyterhub/blob/336d7cfcfaf74087e4ee467d5e3d3bec0c25c3d0/jupyterhub/tests/mocking.py#L295) function in JupyterHub's `mocking` module initializes a database connection for the mocked JupyterHub application instance by calling the `init_db` function of the JupyterHub superclass but also has a `test_clean_db` attribute to ensure that the database is reset to a clean state before running tests.
Raw data
{
"_id": null,
"home_page": "",
"name": "pytest-jupyterhub",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "jupyterhub,plugin,pytest",
"author": "",
"author_email": "Jupyter Contributors <jupyter@googlegroups.com>",
"download_url": "https://files.pythonhosted.org/packages/e4/d6/14c723fd3953038ade0d9afcefd8288409f8e1f53e8d49fe3f101b8ea26a/pytest_jupyterhub-0.0.1.dev0.tar.gz",
"platform": null,
"description": "# Reusable JupyterHub Pytest Plugin\n\n## Description\n\nThis is a reusable pytest plugin for testing JupyterHub's components\n\n**JupyterHub** is a modular and extensible project, with components, like the **proxy**, **authenticator** and **spawner**, that can be easily replaced with alternate implementations. Testing the functionality of these components against JupyterHub is important and it requires various hub setups that can sometimes become complicated.\n\nEach of these hub components and the hub itself define their own testing infrastructure, building everything from the ground up using the **pytest** framework. And some of this complex work is either repetitive across JupyterHub sub-projects, or under-specified for some of them. This has sparked a need to abstract these common parts into a separate testing framework.\n\nThe goal is to provide importable testing utilities to make it easier for contributors to write tests for the various hub components.\nThis will involve creating and using **fixtures** and **mocks**.\n\nA **Fixture** is a function that is used to prepare and clean up the environment for a test function. Fixtures can be used to set up test data, test environment, and other resources that are needed by test functions.\nFor more information on Fixtures, check out this [pytest documentation](https://docs.pytest.org/en/latest/explanation/fixtures.html) on fixtures.\n\nA **Mock** is an object that simulates the behavior of another object such as a class or function. They are used to simulate the behavior of real objects for testing purposes.\nFor more information on Mocks, check out this [unittest documentation](https://docs.python.org/3/library/unittest.mock.html) on the mock module.\n\n**Example:**\n\nThe [init_db](https://github.com/jupyterhub/jupyterhub/blob/336d7cfcfaf74087e4ee467d5e3d3bec0c25c3d0/jupyterhub/app.py#L1804) function in JupyterHub's `app` module initializes a connection to a database using SQLAlchemy's ORM (Object-Relational Mapper).\n\nHowever, the mock [init_db](https://github.com/jupyterhub/jupyterhub/blob/336d7cfcfaf74087e4ee467d5e3d3bec0c25c3d0/jupyterhub/tests/mocking.py#L295) function in JupyterHub's `mocking` module initializes a database connection for the mocked JupyterHub application instance by calling the `init_db` function of the JupyterHub superclass but also has a `test_clean_db` attribute to ensure that the database is reset to a clean state before running tests.\n",
"bugtrack_url": null,
"license": "BSD 3-Clause License Copyright (c) 2022, JupyterHub Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. 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. 3. Neither the name of the copyright holder 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 HOLDER 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.",
"summary": "A reusable JupyterHub pytest plugin",
"version": "0.0.1.dev0",
"split_keywords": [
"jupyterhub",
"plugin",
"pytest"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d0fddea9c125cc8594f1b5ee16c1112e253d0bc30779a4a28092998561ca579e",
"md5": "ef0cccd8dfb2fd5f1408e0b550d2b174",
"sha256": "df8771a9d8d4269299ed1912e7200531e0b533c8dd23b8314c495b3ee46304ff"
},
"downloads": -1,
"filename": "pytest_jupyterhub-0.0.1.dev0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ef0cccd8dfb2fd5f1408e0b550d2b174",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 6191,
"upload_time": "2023-04-13T09:53:24",
"upload_time_iso_8601": "2023-04-13T09:53:24.283271Z",
"url": "https://files.pythonhosted.org/packages/d0/fd/dea9c125cc8594f1b5ee16c1112e253d0bc30779a4a28092998561ca579e/pytest_jupyterhub-0.0.1.dev0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e4d614c723fd3953038ade0d9afcefd8288409f8e1f53e8d49fe3f101b8ea26a",
"md5": "df07acc5bbb14a10fa71770b4ba838c7",
"sha256": "a1e023387843a763497c93dbf2c70e4fb02519c66f55db78310be8e1e82b0153"
},
"downloads": -1,
"filename": "pytest_jupyterhub-0.0.1.dev0.tar.gz",
"has_sig": false,
"md5_digest": "df07acc5bbb14a10fa71770b4ba838c7",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 28350,
"upload_time": "2023-04-13T09:53:27",
"upload_time_iso_8601": "2023-04-13T09:53:27.162067Z",
"url": "https://files.pythonhosted.org/packages/e4/d6/14c723fd3953038ade0d9afcefd8288409f8e1f53e8d49fe3f101b8ea26a/pytest_jupyterhub-0.0.1.dev0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-04-13 09:53:27",
"github": false,
"gitlab": false,
"bitbucket": false,
"lcname": "pytest-jupyterhub"
}