Skip to main content

Pytest plugin to load resource files relative to test code and to expect values to match them.

Project description

pytest-respect

Pytest plugin to load resource files relative to test code and to expect values to match them. The name is a contraction of resources.expect, which is frequently typed when using this plugin.

The primary use-case is running tests over moderately large datasets where adding them as constants in the test code would be cumbersome. This happens frequently with integration tests or when retrofitting tests onto an existing code-base.

Example

The absolute simplest example is the following test. If it is found in a file called foo/test_stuff.py, then it will load the content of foo/test_stuff/test_computation__input.json, run the compute function on it, and assert that the output exactly matches the content of the file foo/test_stuff/test_computation__output.json.

def test_computation(resources):
    """Running compute on input.json creates an output matching output.json"""
    input = resources.load_json("input")
    output = compute(input)
    resources.expect_json(output, "output")

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_respect-0.0.1.tar.gz (51.0 kB view details)

Uploaded Source

Built Distribution

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

pytest_respect-0.0.1-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file pytest_respect-0.0.1.tar.gz.

File metadata

  • Download URL: pytest_respect-0.0.1.tar.gz
  • Upload date:
  • Size: 51.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.4

File hashes

Hashes for pytest_respect-0.0.1.tar.gz
Algorithm Hash digest
SHA256 8641423eef47409a9159137753b15e4b7205dfd71f1f12e5e3b5ea2e883fc626
MD5 dc986b03b41c3a261aa16a5617247963
BLAKE2b-256 ab099693f2fe2cecc437e7ec93f3972e303db24497eaa8ec3d81df94610866ed

See more details on using hashes here.

File details

Details for the file pytest_respect-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_respect-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 21c132af884ce0ab6c4842d83dd972e121d314079d5f84f62fbdc299999c0192
MD5 9e27abbe7b1cbf21e801dd2d442d18b0
BLAKE2b-256 adccd80d9dd3e2a2a1fdc80eba58c11acec41342be48605ef60f21b28559f0d4

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