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.8.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.8.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for pytest_httpchain_templates-0.8.0.tar.gz
Algorithm Hash digest
SHA256 d74e5c45f726c989b755e511c9b30ac8368abb6876c30331cc3ca47dd87bc2b0
MD5 9cab1249ea0b08eab63efd86356416ec
BLAKE2b-256 0a105a721680623eb6848f85eb72b8022942995507960bc23f191e3847a47ec5

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pytest_httpchain_templates-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 75df3f56f72a9a00a376ca692c72f9f11a80d989e53b6fa19beb35d7936b3bb9
MD5 c18b25369b26e4db00b4b307101a8ce7
BLAKE2b-256 a7609aa1e0dda8e3d37ff9bb6f73eccee2124929112fb72646ba4069495e9cd9

See more details on using hashes here.

Provenance

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