Skip to main content

A reusable JupyterHub pytest plugin

Project description

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 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 on the mock module.

Example:

The init_db function in JupyterHub's app module initializes a connection to a database using SQLAlchemy's ORM (Object-Relational Mapper).

However, the mock init_db 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_jupyterhub-0.0.1.dev0.tar.gz (28.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_jupyterhub-0.0.1.dev0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file pytest_jupyterhub-0.0.1.dev0.tar.gz.

File metadata

  • Download URL: pytest_jupyterhub-0.0.1.dev0.tar.gz
  • Upload date:
  • Size: 28.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for pytest_jupyterhub-0.0.1.dev0.tar.gz
Algorithm Hash digest
SHA256 a1e023387843a763497c93dbf2c70e4fb02519c66f55db78310be8e1e82b0153
MD5 df07acc5bbb14a10fa71770b4ba838c7
BLAKE2b-256 e4d614c723fd3953038ade0d9afcefd8288409f8e1f53e8d49fe3f101b8ea26a

See more details on using hashes here.

File details

Details for the file pytest_jupyterhub-0.0.1.dev0-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_jupyterhub-0.0.1.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 df8771a9d8d4269299ed1912e7200531e0b533c8dd23b8314c495b3ee46304ff
MD5 ef0cccd8dfb2fd5f1408e0b550d2b174
BLAKE2b-256 d0fddea9c125cc8594f1b5ee16c1112e253d0bc30779a4a28092998561ca579e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page