Skip to main content

Templating support for pytest-httpchain

Project description

pytest-httpchain-templates

The {{ expression }} template engine for pytest-httpchain.

This package evaluates template expressions and walks them recursively through strings, dicts, lists, Pydantic models, and SimpleNamespace objects against a context. A value that is a single {{ ... }} expression preserves its type (walk("{{ 42 }}", {}) returns the int 42), while mixed content interpolates into a string. Expressions are evaluated with simpleeval and a curated set of built-ins (type conversions, len/min/max/sum, range, uuid4(), env(), and the context helpers get() / exists()). Note that scenario files are treated as trusted input — simpleeval blocks accidental footguns but is not a hardened sandbox, so templates can run arbitrary Python by design.

Role in the workspace

pytest-httpchain shares a key-value context across the stages of a scenario. When a stage runs, the plugin walks its request model through this engine, substituting saved values, fixtures, parametrize parameters, and substitution variables before the HTTP request is sent. It is published separately so the evaluation logic can be reused and tested in isolation.

Usage

from pytest_httpchain_templates.substitution import walk
from pytest_httpchain_templates.exceptions import TemplatesError

try:
    walk("{{ name }}", {"name": "Alice"})            # "Alice"
    walk("{{ [x * 2 for x in items] }}", {"items": [1, 2]})  # [2, 4]
    walk("{{ get('missing', 'default') }}", {})      # "default"
except TemplatesError as e:
    print(f"template error: {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_templates-0.7.0.tar.gz (4.7 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_templates-0.7.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for pytest_httpchain_templates-0.7.0.tar.gz
Algorithm Hash digest
SHA256 d6632b2ab225c36430cbeffd7a0588457ff8eae8d2b7f97f2e5a6dee01ce0768
MD5 e4de681a094ca531ae5d210f3ef81555
BLAKE2b-256 309693631a6191103ad1b23c1e7941a7a0025038feee419635da3b4e464d5b9b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_httpchain_templates-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_templates-0.7.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_httpchain_templates-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4844dcfd574aa0ba9840fdb16d2c6feb78d646befcb8e602c5e6cb41ce452b56
MD5 4a4d3ecf1a985171fa2e5807193fa6ed
BLAKE2b-256 1276bfb2c381d36e91fd5193ca629a33b212674951f6e761a99e2ada67118414

See more details on using hashes here.

Provenance

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