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.7.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.7.0-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for pytest_httpchain_userfunc-0.7.0.tar.gz
Algorithm Hash digest
SHA256 bf669c568e595e88e154b6a1a87a3014923c49b663261cfa176f6003d5559283
MD5 1ce66c99263b89a99e0b4d30581e27c2
BLAKE2b-256 c8a4ee5644faa9ffd6b962c2cadf866bb0408f61edb40031f1bd45d19ab23252

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pytest_httpchain_userfunc-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f7126565b5899928522b909e5e11d17f1ab79fc46a02e372f4bfcfda237bff47
MD5 520423fd36273086622992085bdc86ed
BLAKE2b-256 2a234ebe3601a30292b8a88472647870d513bffef42fa2430c6a2de488777c91

See more details on using hashes here.

Provenance

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