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

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for pytest_httpchain_userfunc-0.8.0.tar.gz
Algorithm Hash digest
SHA256 eae638d7a6689cc249a5251cc03d0732629a4b67538eb6f499cd66f7d5895f27
MD5 51e5461cf200d286c34210841237110c
BLAKE2b-256 92e433e908ef996c146d0cdc40728999fcfe376cb75d6392a8d1e3211b9628a9

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_httpchain_userfunc-0.8.0.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.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_httpchain_userfunc-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0f803da807cd714880c771eafa693f1edab3471ce89abeb730adeb0eca8a7eb7
MD5 adda34301278b9d152106995f53a998c
BLAKE2b-256 06e9611ef8db1355178d7ae55bf9d6f64509fb2f1db969c0fd40668ee670e392

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_httpchain_userfunc-0.8.0-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