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.1.tar.gz (5.2 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.1-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for pytest_httpchain_templates-0.8.1.tar.gz
Algorithm Hash digest
SHA256 bc73aef61750726dda056651855722757bbd6ca6f4a1a732065b496b4ec8bdd6
MD5 8e8fa1d6d2da9a3e66ce9a7dfd51e2d0
BLAKE2b-256 c99ac8a0109bb46343e2b3b908ccef9be8000c2480aaef9da8a0acddcbc4923f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pytest_httpchain_templates-0.8.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7f1fd91f5e88ac9ba54f61da715f232da44691975d8b2ce2e28dacec52a76f88
MD5 1b58a4e8947df08b22547bd366a17a70
BLAKE2b-256 e4850079dccbebe767f509771bfbf8f75c8d4a36b8c3c08847b54a76007538f5

See more details on using hashes here.

Provenance

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