Skip to main content

User functions support for pytest-httpchain

Project description

pytest-httpchain-userfunc

Dynamic import and invocation of user-defined functions for pytest-httpchain.

This package resolves a function from an explicit module.path:function_name reference and calls it. A bare name with no module path is rejected. It exposes import_function (resolve only), call_function (resolve and call), and wrap_function (build a callable with default args/kwargs that are merged with call-time arguments). Import and runtime failures are raised as UserFunctionError with the underlying cause appended to the message, so the reason is visible even where only the message text is rendered.

Role in the workspace

pytest-httpchain lets a scenario hook into user Python for custom authentication, response verification, data extraction, and substitution functions, each referenced as module:function. The plugin uses this package to import and invoke those references at the right point in a stage's lifecycle. It is published separately so the import/invocation logic can be reused and tested on its own.

Usage

from pytest_httpchain_userfunc import call_function, wrap_function, UserFunctionError

try:
    result = call_function("mypackage.checks:status_ok", response)

    wrapped = wrap_function("mypackage.checks:equals", default_kwargs={"expected": 200})
    wrapped(response)  # default_kwargs merged with call-time kwargs
except UserFunctionError as e:
    print(f"user function failed: {e}")

Links

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_httpchain_userfunc-0.8.1.tar.gz (3.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_httpchain_userfunc-0.8.1-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file pytest_httpchain_userfunc-0.8.1.tar.gz.

File metadata

File hashes

Hashes for pytest_httpchain_userfunc-0.8.1.tar.gz
Algorithm Hash digest
SHA256 aeb75de489a60b42189f3ebc3c310ead367ee9aa492e10cf09bb796f2a910e02
MD5 958c1803431576398ddba68ea2c3e8e8
BLAKE2b-256 e9b478a0305b8f1823ef5fa2e4d3c8c9434fb10d82128a100786f5963afaa117

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_httpchain_userfunc-0.8.1.tar.gz:

Publisher: publish.yml on aeresov/pytest-httpchain

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytest_httpchain_userfunc-0.8.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_httpchain_userfunc-0.8.1-py3-none-any.whl
Algorithm Hash digest
SHA256 249579a0e940bdf697066103787b7b6375e6822df73043b764959ba4efdbeefd
MD5 b4a46d10d911ce5dcbb136d49e9fefe2
BLAKE2b-256 d7860a28243d8d518f95bee7d9ad1bbd89e12c88ac3010393a6cc8c9671a1d44

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_httpchain_userfunc-0.8.1-py3-none-any.whl:

Publisher: publish.yml on aeresov/pytest-httpchain

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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