pytest-httpchain 0.15.1__tar.gz → 0.15.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. {pytest_httpchain-0.15.1 → pytest_httpchain-0.15.2}/PKG-INFO +2 -2
  2. {pytest_httpchain-0.15.1 → pytest_httpchain-0.15.2}/pyproject.toml +4 -3
  3. {pytest_httpchain-0.15.1 → pytest_httpchain-0.15.2}/pyproject.toml.orig +5 -3
  4. {pytest_httpchain-0.15.1 → pytest_httpchain-0.15.2}/src/pytest_httpchain/carrier.py +16 -3
  5. {pytest_httpchain-0.15.1 → pytest_httpchain-0.15.2}/src/pytest_httpchain/models/entities.py +1 -1
  6. {pytest_httpchain-0.15.1 → pytest_httpchain-0.15.2}/src/pytest_httpchain/plugin.py +39 -6
  7. {pytest_httpchain-0.15.1 → pytest_httpchain-0.15.2}/src/pytest_httpchain/response_steps.py +1 -1
  8. {pytest_httpchain-0.15.1 → pytest_httpchain-0.15.2}/LICENSE +0 -0
  9. {pytest_httpchain-0.15.1 → pytest_httpchain-0.15.2}/README.md +0 -0
  10. {pytest_httpchain-0.15.1 → pytest_httpchain-0.15.2}/src/pytest_httpchain/__init__.py +0 -0
  11. {pytest_httpchain-0.15.1 → pytest_httpchain-0.15.2}/src/pytest_httpchain/cli.py +0 -0
  12. {pytest_httpchain-0.15.1 → pytest_httpchain-0.15.2}/src/pytest_httpchain/constants.py +0 -0
  13. {pytest_httpchain-0.15.1 → pytest_httpchain-0.15.2}/src/pytest_httpchain/dataflow.py +0 -0
  14. {pytest_httpchain-0.15.1 → pytest_httpchain-0.15.2}/src/pytest_httpchain/errors.py +0 -0
  15. {pytest_httpchain-0.15.1 → pytest_httpchain-0.15.2}/src/pytest_httpchain/factory.py +0 -0
  16. {pytest_httpchain-0.15.1 → pytest_httpchain-0.15.2}/src/pytest_httpchain/har_writer.py +0 -0
  17. {pytest_httpchain-0.15.1 → pytest_httpchain-0.15.2}/src/pytest_httpchain/jsonref/__init__.py +0 -0
  18. {pytest_httpchain-0.15.1 → pytest_httpchain-0.15.2}/src/pytest_httpchain/jsonref/exceptions.py +0 -0
  19. {pytest_httpchain-0.15.1 → pytest_httpchain-0.15.2}/src/pytest_httpchain/jsonref/loader.py +0 -0
  20. {pytest_httpchain-0.15.1 → pytest_httpchain-0.15.2}/src/pytest_httpchain/jsonref/plumbing/__init__.py +0 -0
  21. {pytest_httpchain-0.15.1 → pytest_httpchain-0.15.2}/src/pytest_httpchain/jsonref/plumbing/circular.py +0 -0
  22. {pytest_httpchain-0.15.1 → pytest_httpchain-0.15.2}/src/pytest_httpchain/jsonref/plumbing/path.py +0 -0
  23. {pytest_httpchain-0.15.1 → pytest_httpchain-0.15.2}/src/pytest_httpchain/jsonref/plumbing/reference.py +0 -0
  24. {pytest_httpchain-0.15.1 → pytest_httpchain-0.15.2}/src/pytest_httpchain/models/__init__.py +0 -0
  25. {pytest_httpchain-0.15.1 → pytest_httpchain-0.15.2}/src/pytest_httpchain/models/types.py +0 -0
  26. {pytest_httpchain-0.15.1 → pytest_httpchain-0.15.2}/src/pytest_httpchain/py.typed +0 -0
  27. {pytest_httpchain-0.15.1 → pytest_httpchain-0.15.2}/src/pytest_httpchain/report_formatter.py +0 -0
  28. {pytest_httpchain-0.15.1 → pytest_httpchain-0.15.2}/src/pytest_httpchain/request_builder.py +0 -0
  29. {pytest_httpchain-0.15.1 → pytest_httpchain-0.15.2}/src/pytest_httpchain/schema.py +0 -0
  30. {pytest_httpchain-0.15.1 → pytest_httpchain-0.15.2}/src/pytest_httpchain/scoping.py +0 -0
  31. {pytest_httpchain-0.15.1 → pytest_httpchain-0.15.2}/src/pytest_httpchain/templates/__init__.py +0 -0
  32. {pytest_httpchain-0.15.1 → pytest_httpchain-0.15.2}/src/pytest_httpchain/templates/exceptions.py +0 -0
  33. {pytest_httpchain-0.15.1 → pytest_httpchain-0.15.2}/src/pytest_httpchain/templates/expressions.py +0 -0
  34. {pytest_httpchain-0.15.1 → pytest_httpchain-0.15.2}/src/pytest_httpchain/templates/substitution.py +0 -0
  35. {pytest_httpchain-0.15.1 → pytest_httpchain-0.15.2}/src/pytest_httpchain/userfunc.py +0 -0
  36. {pytest_httpchain-0.15.1 → pytest_httpchain-0.15.2}/src/pytest_httpchain/utils.py +0 -0
  37. {pytest_httpchain-0.15.1 → pytest_httpchain-0.15.2}/src/pytest_httpchain/validation/__init__.py +0 -0
  38. {pytest_httpchain-0.15.1 → pytest_httpchain-0.15.2}/src/pytest_httpchain/validation/deep.py +0 -0
  39. {pytest_httpchain-0.15.1 → pytest_httpchain-0.15.2}/src/pytest_httpchain/validation/diagnostics.py +0 -0
  40. {pytest_httpchain-0.15.1 → pytest_httpchain-0.15.2}/src/pytest_httpchain/validation/loader.py +0 -0
  41. {pytest_httpchain-0.15.1 → pytest_httpchain-0.15.2}/src/pytest_httpchain/validation/semantic.py +0 -0
  42. {pytest_httpchain-0.15.1 → pytest_httpchain-0.15.2}/src/pytest_httpchain/validation/validate.py +0 -0
  43. {pytest_httpchain-0.15.1 → pytest_httpchain-0.15.2}/src/pytest_httpchain/warnings.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pytest-httpchain
3
- Version: 0.15.1
3
+ Version: 0.15.2
4
4
  Summary: pytest plugin for HTTP testing using JSON files
5
5
  Keywords: testing,pytest,httpx,http,api,integration-testing
6
6
  Author: Alexander Eresov
@@ -24,7 +24,7 @@ Requires-Dist: pydantic>=2.13.4
24
24
  Requires-Dist: referencing>=0.28.4
25
25
  Requires-Dist: pyrate-limiter>=4.2.0
26
26
  Requires-Dist: pytest>=9.0
27
- Requires-Dist: simpleeval>=1.0.3
27
+ Requires-Dist: simpleeval>=1.0.8
28
28
  Requires-Dist: typer>=0.26.0
29
29
  Requires-Python: >=3.13
30
30
  Project-URL: Repository, https://github.com/aeresov/pytest-httpchain
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "pytest-httpchain"
3
- version = "0.15.1"
3
+ version = "0.15.2"
4
4
  description = "pytest plugin for HTTP testing using JSON files"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.13"
@@ -14,7 +14,7 @@ dependencies = [
14
14
  "referencing>=0.28.4",
15
15
  "pyrate-limiter>=4.2.0",
16
16
  "pytest>=9.0",
17
- "simpleeval>=1.0.3",
17
+ "simpleeval>=1.0.8",
18
18
  "typer>=0.26.0",
19
19
  ]
20
20
  keywords = [
@@ -59,6 +59,7 @@ dev = [
59
59
  "flask-httpauth>=4.8.0",
60
60
  "import-linter>=2.0",
61
61
  "ruff>=0.12.1",
62
+ "ty>=0.0.84",
62
63
  "coverage[toml]>=7.10",
63
64
  "pytest-datadir>=1.7.2",
64
65
  "pytest-order>=1.3.0",
@@ -181,5 +182,5 @@ source_modules = ["pytest_httpchain.models"]
181
182
  forbidden_modules = ["pytest_httpchain.jsonref"]
182
183
 
183
184
  [build-system]
184
- requires = ["uv_build>=0.11,<0.12"]
185
+ requires = ["uv_build>=0.12,<0.13"]
185
186
  build-backend = "uv_build"
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "pytest-httpchain"
3
- version = "0.15.1"
3
+ version = "0.15.2"
4
4
  description = "pytest plugin for HTTP testing using JSON files"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.13"
@@ -15,7 +15,8 @@ dependencies = [
15
15
  "referencing>=0.28.4",
16
16
  "pyrate-limiter>=4.2.0",
17
17
  "pytest>=9.0",
18
- "simpleeval>=1.0.3",
18
+ # 1.0.8 blocks sandbox escapes through the operator module and os.exec*/spawn*.
19
+ "simpleeval>=1.0.8",
19
20
  # 0.26.0 is the first release that stopped importing the deprecated
20
21
  # `click.utils.get_binary_stream`; with `filterwarnings = error` any older
21
22
  # typer fails collection against current click.
@@ -46,6 +47,7 @@ dev = [
46
47
  "flask-httpauth>=4.8.0",
47
48
  "import-linter>=2.0",
48
49
  "ruff>=0.12.1",
50
+ "ty>=0.0.84",
49
51
  "coverage[toml]>=7.10", # `patch = ["subprocess"]` needs 7.10
50
52
 
51
53
  "pytest-datadir>=1.7.2",
@@ -65,7 +67,7 @@ docs = [
65
67
  default-groups = ["dev", "docs"]
66
68
 
67
69
  [build-system]
68
- requires = ["uv_build>=0.11,<0.12"]
70
+ requires = ["uv_build>=0.12,<0.13"]
69
71
  build-backend = "uv_build"
70
72
 
71
73
  [tool.uv.build-backend]
@@ -26,7 +26,7 @@ from dataclasses import dataclass
26
26
  from datetime import UTC, datetime
27
27
  from pathlib import Path
28
28
  from types import SimpleNamespace
29
- from typing import Any, ClassVar, cast
29
+ from typing import Any, ClassVar
30
30
 
31
31
  import httpx
32
32
  import pytest
@@ -142,6 +142,19 @@ def _parallel_int(field: str, value: Any) -> int:
142
142
  return int(number)
143
143
 
144
144
 
145
+ def _parallel_values(field: str, value: Any) -> list[Any]:
146
+ """A walk()-resolved ``parallel.foreach`` step's values, or a stage failure.
147
+
148
+ Like the numeric fields, both step kinds also accept a template string, so a
149
+ template resolving to another template arrives here as text: iterated, it
150
+ ran one iteration per character (``individual``) or escaped as a bare
151
+ TypeError (``combinations``).
152
+ """
153
+ if not isinstance(value, list):
154
+ raise StageExecutionError(f"parallel.foreach {field} must resolve to a list, got {value!r}")
155
+ return value
156
+
157
+
145
158
  def fresh_scenario_state() -> dict[str, Any]:
146
159
  """The per-scenario mutable class state, in its pristine form.
147
160
 
@@ -375,9 +388,9 @@ class Carrier:
375
388
  match step:
376
389
  case IndividualParameter(individual=individual):
377
390
  param_name = next(iter(individual))
378
- steps.append((param_name, individual[param_name]))
391
+ steps.append((param_name, _parallel_values(f"individual '{param_name}'", individual[param_name])))
379
392
  case CombinationsParameter(combinations=combinations):
380
- steps.append((None, cast(list[Any], combinations)))
393
+ steps.append((None, _parallel_values("combinations", combinations)))
381
394
  case _:
382
395
  raise RuntimeError(f"Unhandled foreach step: {type(step).__name__}")
383
396
  check_cap(math.prod(len(values) for _, values in steps))
@@ -59,7 +59,7 @@ def _create_discriminator(class_to_tag: dict[type, str]) -> Callable[[Any], str]
59
59
  return min(found)
60
60
 
61
61
  # Name the offending key, so the validation error points at it.
62
- return next(iter(v), "(empty object)") # ty: ignore[invalid-return-type]
62
+ return next(iter(v), "(empty object)")
63
63
 
64
64
  tag = class_to_tag.get(type(v))
65
65
  if tag:
@@ -135,7 +135,9 @@ class JsonModule(pytest.Module):
135
135
 
136
136
 
137
137
  # Collection order, recorded before any sorter runs: the regroup tiebreaker.
138
- _ORIGINAL_POSITIONS: pytest.StashKey[dict[pytest.Item, int]] = pytest.StashKey()
138
+ # Keyed by id(item), not the item: up to pytest 9.1 an item hashes its `_nodeid`,
139
+ # which an xdist loadgroup worker rewrites between recording and lookup.
140
+ _ORIGINAL_POSITIONS: pytest.StashKey[dict[int, int]] = pytest.StashKey()
139
141
 
140
142
 
141
143
  def _carrier_class(item: pytest.Item) -> type[Carrier] | None:
@@ -149,7 +151,7 @@ def _stage_index(item: pytest.Item) -> int:
149
151
  return getattr(getattr(item, "function", None), "_httpchain_stage_index", 0)
150
152
 
151
153
 
152
- def _regroup_carrier_items(items: list[pytest.Item], original_position: dict[pytest.Item, int]) -> None:
154
+ def _regroup_carrier_items(items: list[pytest.Item], original_position: dict[int, int]) -> None:
153
155
  """Re-sort collected items so each scenario class's stages run contiguously,
154
156
  in stage order.
155
157
 
@@ -158,7 +160,8 @@ def _regroup_carrier_items(items: list[pytest.Item], original_position: dict[pyt
158
160
  (a user-installed pytest-order acting on user-authored ``order(...)`` marks,
159
161
  pytest-randomly's shuffle, core's ``--ff``). Each class is pulled together
160
162
  at its first item (preserving inter-class order), with ``original_position``
161
- breaking ties so parametrized instances of a stage keep collection order.
163
+ (keyed by ``id(item)``) breaking ties so parametrized instances of a stage
164
+ keep collection order.
162
165
  """
163
166
  buckets: dict[type[Carrier], list[pytest.Item]] = {}
164
167
  for item in items:
@@ -168,7 +171,7 @@ def _regroup_carrier_items(items: list[pytest.Item], original_position: dict[pyt
168
171
  return
169
172
 
170
173
  def stage_key(item: pytest.Item) -> tuple[int, int]:
171
- return (_stage_index(item), original_position.get(item, sys.maxsize))
174
+ return (_stage_index(item), original_position.get(id(item), sys.maxsize))
172
175
 
173
176
  for bucket in buckets.values():
174
177
  bucket.sort(key=stage_key)
@@ -185,6 +188,34 @@ def _regroup_carrier_items(items: list[pytest.Item], original_position: dict[pyt
185
188
  items[:] = regrouped
186
189
 
187
190
 
191
+ def _apply_xdist_group_nodeids(items: list[pytest.Item]) -> None:
192
+ """Make the ``@<group>`` suffix xdist writes into a scenario item's nodeid
193
+ actually reach the nodeid, so ``--dist loadgroup`` keeps a chain on one worker.
194
+
195
+ An xdist worker encodes each item's ``xdist_group`` by assigning the private
196
+ ``item._nodeid``, and the controller's loadgroup scheduler groups by the
197
+ text after ``@``. Up to pytest 9.1 ``_nodeid`` backs ``nodeid``. From pytest
198
+ 9.2 (pytest-dev/pytest#14758) ``nodeid`` is derived from a structured
199
+ ``item._id`` instead, so the assignment only adds an unused attribute: the
200
+ suffix is lost, every stage becomes its own work unit, and a scenario's stages
201
+ scatter across workers. This carries the id xdist wrote over to ``_id``.
202
+ Where ``_nodeid`` still backs ``nodeid``, or xdist wrote nothing (another dist
203
+ mode, no group), there is no mismatch and nothing changes.
204
+ """
205
+ for item in items:
206
+ if _carrier_class(item) is None:
207
+ continue
208
+ # From 9.2 `_nodeid` is not a slot, so xdist's write lands in __dict__.
209
+ written = item.__dict__.get("_nodeid")
210
+ node_id = getattr(item, "_id", None)
211
+ if written is None or node_id is None or written == item.nodeid:
212
+ continue
213
+ # parse() caches the exact string, so nodeid reads back verbatim. setattr
214
+ # because `_id` exists only from 9.2: a plain assignment fails the type
215
+ # check on older pytest, and a `ty: ignore` goes unused on newer.
216
+ setattr(item, "_id", type(node_id).parse(written)) # noqa: B010
217
+
218
+
188
219
  @pytest.hookimpl(wrapper=True)
189
220
  def pytest_collection_modifyitems(config: pytest.Config, items: list[pytest.Item]) -> Any:
190
221
  """Enforce chain contiguity after the non-wrapper sorters have run.
@@ -192,10 +223,12 @@ def pytest_collection_modifyitems(config: pytest.Config, items: list[pytest.Item
192
223
  Pre-yield the items are still in collection order, which is recorded as the
193
224
  tiebreaker; post-yield runs after pytest-order, pytest-randomly and friends.
194
225
  Sorters written as tryfirst wrappers finish even later — `pytest_collection_finish`
195
- catches those.
226
+ catches those. Post-yield is also after an xdist worker has written its
227
+ loadgroup nodeid suffix, which `_apply_xdist_group_nodeids` needs.
196
228
  """
197
- config.stash[_ORIGINAL_POSITIONS] = {item: i for i, item in enumerate(items)}
229
+ config.stash[_ORIGINAL_POSITIONS] = {id(item): i for i, item in enumerate(items)}
198
230
  result = yield
231
+ _apply_xdist_group_nodeids(items)
199
232
  _regroup_carrier_items(items, config.stash[_ORIGINAL_POSITIONS])
200
233
  return result
201
234
 
@@ -65,7 +65,7 @@ def process_save(save_model: Save, response: httpx.Response, context: ChainMap[s
65
65
 
66
66
  if not isinstance(func_result, dict):
67
67
  raise SaveError(f"Save function must return dict, got {type(func_result).__name__}")
68
- step_saved.update(func_result) # ty: ignore[no-matching-overload]
68
+ step_saved.update(func_result)
69
69
 
70
70
  case _:
71
71
  raise RuntimeError(f"Unhandled save type: {type(save_model).__name__}")