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
- Documentation: https://aeresov.github.io/pytest-httpchain/
- Source and issues: https://github.com/aeresov/pytest-httpchain
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytest_httpchain_templates-0.8.0.tar.gz.
File metadata
- Download URL: pytest_httpchain_templates-0.8.0.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d74e5c45f726c989b755e511c9b30ac8368abb6876c30331cc3ca47dd87bc2b0
|
|
| MD5 |
9cab1249ea0b08eab63efd86356416ec
|
|
| BLAKE2b-256 |
0a105a721680623eb6848f85eb72b8022942995507960bc23f191e3847a47ec5
|
Provenance
The following attestation bundles were made for pytest_httpchain_templates-0.8.0.tar.gz:
Publisher:
publish.yml on aeresov/pytest-httpchain
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytest_httpchain_templates-0.8.0.tar.gz -
Subject digest:
d74e5c45f726c989b755e511c9b30ac8368abb6876c30331cc3ca47dd87bc2b0 - Sigstore transparency entry: 1823980170
- Sigstore integration time:
-
Permalink:
aeresov/pytest-httpchain@a18fdb9340066f3a4a0a285e42007bec82a2d2d3 -
Branch / Tag:
refs/tags/v0.8.0 - Owner: https://github.com/aeresov
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a18fdb9340066f3a4a0a285e42007bec82a2d2d3 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pytest_httpchain_templates-0.8.0-py3-none-any.whl.
File metadata
- Download URL: pytest_httpchain_templates-0.8.0-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
75df3f56f72a9a00a376ca692c72f9f11a80d989e53b6fa19beb35d7936b3bb9
|
|
| MD5 |
c18b25369b26e4db00b4b307101a8ce7
|
|
| BLAKE2b-256 |
a7609aa1e0dda8e3d37ff9bb6f73eccee2124929112fb72646ba4069495e9cd9
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytest_httpchain_templates-0.8.0-py3-none-any.whl -
Subject digest:
75df3f56f72a9a00a376ca692c72f9f11a80d989e53b6fa19beb35d7936b3bb9 - Sigstore transparency entry: 1823981746
- Sigstore integration time:
-
Permalink:
aeresov/pytest-httpchain@a18fdb9340066f3a4a0a285e42007bec82a2d2d3 -
Branch / Tag:
refs/tags/v0.8.0 - Owner: https://github.com/aeresov
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a18fdb9340066f3a4a0a285e42007bec82a2d2d3 -
Trigger Event:
release
-
Statement type: