pytest-httpchain 0.17.0__tar.gz → 0.17.1__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.
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/PKG-INFO +1 -1
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/pyproject.toml +1 -1
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/pyproject.toml.orig +1 -1
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/dataflow.py +6 -17
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/har_writer.py +3 -3
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/importers/builder.py +8 -2
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/jsonref/plumbing/path.py +6 -0
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/models/entities.py +3 -4
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/report_formatter.py +4 -4
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/scoping.py +44 -15
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/templates/substitution.py +12 -3
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/userfunc.py +4 -4
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/validation/deep.py +6 -2
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/LICENSE +0 -0
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/README.md +0 -0
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/__init__.py +0 -0
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/body_schema.py +0 -0
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/carrier.py +0 -0
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/cli.py +0 -0
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/constants.py +0 -0
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/errors.py +0 -0
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/factory.py +0 -0
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/importers/__init__.py +0 -0
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/importers/curl.py +0 -0
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/importers/har.py +0 -0
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/jsonref/__init__.py +0 -0
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/jsonref/equality.py +0 -0
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/jsonref/exceptions.py +0 -0
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/jsonref/jsonc.py +0 -0
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/jsonref/loader.py +0 -0
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/jsonref/plumbing/__init__.py +0 -0
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/jsonref/plumbing/circular.py +0 -0
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/jsonref/plumbing/reference.py +0 -0
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/models/__init__.py +0 -0
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/models/types.py +0 -0
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/parallel_stats.py +0 -0
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/plugin.py +0 -0
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/py.typed +0 -0
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/redaction.py +0 -0
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/request_builder.py +0 -0
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/response_steps.py +0 -0
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/schema.py +0 -0
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/templates/__init__.py +0 -0
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/templates/exceptions.py +0 -0
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/templates/expressions.py +0 -0
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/templates/functions.py +0 -0
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/utils.py +0 -0
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/validation/__init__.py +0 -0
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/validation/diagnostics.py +0 -0
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/validation/discovery.py +0 -0
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/validation/loader.py +0 -0
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/validation/semantic.py +0 -0
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/validation/validate.py +0 -0
- {pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/warnings.py +0 -0
|
@@ -13,9 +13,8 @@ from pytest_httpchain.scoping import (
|
|
|
13
13
|
RESPONSE_META_NAME,
|
|
14
14
|
defined_names,
|
|
15
15
|
extract_template_variables,
|
|
16
|
-
raw_list_entries,
|
|
17
16
|
raw_stages,
|
|
18
|
-
|
|
17
|
+
response_step_templates,
|
|
19
18
|
stage_scopes,
|
|
20
19
|
substitution_names,
|
|
21
20
|
substitution_step_templates,
|
|
@@ -123,22 +122,12 @@ def analyze_dataflow(scenario: Scenario, test_data: dict[str, Any]) -> DataFlow:
|
|
|
123
122
|
consumes |= _consumed(extract_template_variables(raw.get("parallel"), defined=defined), scope.earlier_saves, scope.pre_iteration_shadows)
|
|
124
123
|
consumes |= _consumed(extract_template_variables(raw.get("retry"), defined=defined), scope.earlier_saves, scope.pre_iteration_shadows)
|
|
125
124
|
consumes |= _consumed(extract_template_variables(raw.get("request"), defined=defined), scope.earlier_saves, scope.request_shadows)
|
|
126
|
-
#
|
|
127
|
-
#
|
|
128
|
-
#
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
own_saves: frozenset[str] = frozenset()
|
|
132
|
-
# raw_list_entries, not an isinstance(list) guard: the name-keyed mapping
|
|
133
|
-
# form of `response` is first-class, and discarding it left every step's
|
|
134
|
-
# raw text unread — so show/graph reported a consuming stage as
|
|
135
|
-
# consuming nothing and dropped the dependency edge entirely.
|
|
136
|
-
raw_response = raw_list_entries(raw.get("response"))
|
|
137
|
-
for k, step in enumerate(stage.response):
|
|
138
|
-
step_raw = raw_response[k] if k < len(raw_response) else None
|
|
139
|
-
step_refs = extract_template_variables(step_raw, defined=defined) - {RESPONSE_META_NAME}
|
|
125
|
+
# The same order-aware iterator the validator uses also sees prior
|
|
126
|
+
# entries inside a substitutions-save step. Those entries resolve in
|
|
127
|
+
# sequence, and only their rendered values can consume an earlier save.
|
|
128
|
+
for templates, own_saves in response_step_templates(stage, raw.get("response")):
|
|
129
|
+
step_refs = extract_template_variables(templates, defined=defined) - {RESPONSE_META_NAME}
|
|
140
130
|
consumes |= _consumed(step_refs, scope.earlier_saves, scope.request_shadows | own_saves)
|
|
141
|
-
own_saves |= frozenset(saved_in_step(step))
|
|
142
131
|
consumes |= _consumed(extract_template_variables(raw.get("always_run"), defined=defined), scope.earlier_saves, scope.always_run_shadows)
|
|
143
132
|
|
|
144
133
|
by_producer: dict[int, list[str]] = {}
|
|
@@ -10,7 +10,7 @@ import hashlib
|
|
|
10
10
|
import json
|
|
11
11
|
import re
|
|
12
12
|
from datetime import UTC, datetime
|
|
13
|
-
from importlib.metadata import version
|
|
13
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
14
14
|
from pathlib import Path
|
|
15
15
|
from typing import Any
|
|
16
16
|
from urllib.parse import parse_qsl, urlparse
|
|
@@ -31,7 +31,7 @@ def _get_version() -> str:
|
|
|
31
31
|
change in-process."""
|
|
32
32
|
try:
|
|
33
33
|
return version("pytest-httpchain")
|
|
34
|
-
except
|
|
34
|
+
except PackageNotFoundError:
|
|
35
35
|
return "unknown"
|
|
36
36
|
|
|
37
37
|
|
|
@@ -103,7 +103,7 @@ def _format_post_data(request: httpx.Request) -> dict[str, Any] | None:
|
|
|
103
103
|
body_text = _body_text(content)
|
|
104
104
|
post_data: dict[str, Any] = {"mimeType": _mime_type(content_type), **body_text}
|
|
105
105
|
|
|
106
|
-
if "application/x-www-form-urlencoded" in content_type and "encoding" not in body_text:
|
|
106
|
+
if "application/x-www-form-urlencoded" in content_type.lower() and "encoding" not in body_text:
|
|
107
107
|
# HAR params are repeated scalar name/value records, not one record with
|
|
108
108
|
# an array value. parse_qsl also preserves the body's original ordering.
|
|
109
109
|
post_data["params"] = [{"name": name, "value": value} for name, value in parse_qsl(body_text["text"], keep_blank_values=True)]
|
{pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/importers/builder.py
RENAMED
|
@@ -741,8 +741,9 @@ class _Builder:
|
|
|
741
741
|
# as a host: absolute, that one URL ignores base_url.
|
|
742
742
|
target = path if base_url is not None and not path.startswith("//") else f"{_origin(url.scheme, url.netloc)}{path}"
|
|
743
743
|
params, query = self.query(url.query, stage)
|
|
744
|
+
empty_query = not url.query and recorded.url.partition("#")[0].endswith("?")
|
|
744
745
|
# Closed before a query holding a placeholder.
|
|
745
|
-
request["url"] = escape(target, closed=query is not None and contains_template(query)) + (f"?{query}" if query is not None else "")
|
|
746
|
+
request["url"] = escape(target, closed=query is not None and contains_template(query)) + (f"?{query or ''}" if query is not None or empty_query else "")
|
|
746
747
|
if params:
|
|
747
748
|
request["params"] = params
|
|
748
749
|
|
|
@@ -821,7 +822,12 @@ class _Builder:
|
|
|
821
822
|
holds a secret, since ``params`` sends a value rendered to null
|
|
822
823
|
empty, where the URL's placeholder fails the stage unset
|
|
823
824
|
(`fields_text`). A piece without ``=`` is sent as an empty value."""
|
|
824
|
-
|
|
825
|
+
if not query:
|
|
826
|
+
return None, None
|
|
827
|
+
pieces = query.split("&")
|
|
828
|
+
# An empty component (a leading, repeated or trailing ampersand) is
|
|
829
|
+
# lost when a query is rewritten as params. Keep such queries intact.
|
|
830
|
+
pairs = _decoded_pairs(pieces) if all(pieces) else None
|
|
825
831
|
if pairs is not None and _mappable([name for name, _ in pairs]) and not self.any_secret(pairs):
|
|
826
832
|
return _grouped([(name, escape(value)) for name, value in pairs]), None
|
|
827
833
|
return None, self.fields_text(query, "query parameter", stage)
|
{pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/jsonref/plumbing/path.py
RENAMED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"""Reference path and JSON pointer helpers for reference resolution."""
|
|
2
2
|
|
|
3
|
+
import re
|
|
3
4
|
import warnings
|
|
4
5
|
from pathlib import Path, PurePosixPath, PureWindowsPath
|
|
5
6
|
|
|
@@ -90,4 +91,9 @@ def parse_json_pointer(pointer: str) -> list[str]:
|
|
|
90
91
|
if not pointer.startswith("/"):
|
|
91
92
|
raise ReferenceResolverError(f"Invalid JSON pointer: {pointer} (must start with '/')")
|
|
92
93
|
|
|
94
|
+
# RFC 6901 reserves ``~`` for the two escapes below. Leaving any other
|
|
95
|
+
# sequence literal would silently select a key the pointer does not name.
|
|
96
|
+
if re.search(r"~(?![01])", pointer):
|
|
97
|
+
raise ReferenceResolverError(f"Invalid JSON pointer: {pointer} (invalid '~' escape)")
|
|
98
|
+
|
|
93
99
|
return [part.replace("~1", "/").replace("~0", "~") for part in pointer[1:].split("/")]
|
|
@@ -1086,7 +1086,7 @@ class IndividualParameter(StrictModel):
|
|
|
1086
1086
|
|
|
1087
1087
|
@model_validator(mode="after")
|
|
1088
1088
|
def validate_ids_match_values(self) -> Self:
|
|
1089
|
-
if self.ids
|
|
1089
|
+
if self.ids is not None:
|
|
1090
1090
|
values = next(iter(self.individual.values()))
|
|
1091
1091
|
if isinstance(values, str): # template form: count unknown until runtime
|
|
1092
1092
|
return self
|
|
@@ -1118,9 +1118,8 @@ class CombinationsParameter(StrictModel):
|
|
|
1118
1118
|
if combo_keys != first_keys:
|
|
1119
1119
|
raise ValueError(f"Combination {i} has different parameters than combination 0")
|
|
1120
1120
|
|
|
1121
|
-
if self.ids and self.combinations:
|
|
1122
|
-
|
|
1123
|
-
raise ValueError(f"Number of ids ({len(self.ids)}) must match number of combinations ({len(self.combinations)})")
|
|
1121
|
+
if self.ids is not None and len(self.ids) != len(self.combinations):
|
|
1122
|
+
raise ValueError(f"Number of ids ({len(self.ids)}) must match number of combinations ({len(self.combinations)})")
|
|
1124
1123
|
return self
|
|
1125
1124
|
|
|
1126
1125
|
|
{pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/report_formatter.py
RENAMED
|
@@ -53,7 +53,7 @@ def format_request(request: httpx.Request, redaction: Redaction = DEFAULT_REDACT
|
|
|
53
53
|
body = f"<Binary content: {len(content)} bytes>"
|
|
54
54
|
else:
|
|
55
55
|
body = _format_body_text(decoded)
|
|
56
|
-
if "application/json" in content_type:
|
|
56
|
+
if "application/json" in content_type.lower():
|
|
57
57
|
try:
|
|
58
58
|
body = _format_json(json.loads(decoded))
|
|
59
59
|
except JSON_PARSE_ERRORS:
|
|
@@ -137,7 +137,7 @@ def format_response(response: httpx.Response, redaction: Redaction = DEFAULT_RED
|
|
|
137
137
|
body = None
|
|
138
138
|
if response.content:
|
|
139
139
|
content_type = response.headers.get("Content-Type", "")
|
|
140
|
-
if "application/json" in content_type:
|
|
140
|
+
if "application/json" in content_type.lower():
|
|
141
141
|
try:
|
|
142
142
|
body = _format_json(response.json())
|
|
143
143
|
except JSON_PARSE_ERRORS:
|
|
@@ -255,7 +255,7 @@ def format_curl(request: httpx.Request, redaction: Redaction = DEFAULT_REDACTION
|
|
|
255
255
|
if lowered == "authorization" and value[: len(_DIGEST_SCHEME)].lower() == _DIGEST_SCHEME:
|
|
256
256
|
notes.append("The Digest Authorization answered one challenge and is left out: add --digest -u 'user:password' to answer a new one.")
|
|
257
257
|
continue
|
|
258
|
-
if lowered == "content-type" and content is None and value.startswith("multipart/"):
|
|
258
|
+
if lowered == "content-type" and content is None and value.lower().startswith("multipart/"):
|
|
259
259
|
# Its boundary is the uncaptured body's: -F writes its own.
|
|
260
260
|
continue
|
|
261
261
|
shown = redaction.header(name, value)
|
|
@@ -265,7 +265,7 @@ def format_curl(request: httpx.Request, redaction: Redaction = DEFAULT_REDACTION
|
|
|
265
265
|
|
|
266
266
|
data: str | None = None
|
|
267
267
|
if content is None:
|
|
268
|
-
if content_type is not None and content_type.startswith("multipart/"):
|
|
268
|
+
if content_type is not None and content_type.lower().startswith("multipart/"):
|
|
269
269
|
notes.append("The multipart body was not captured: add each part with -F 'name=@file'.")
|
|
270
270
|
else:
|
|
271
271
|
notes.append("The streamed body was not captured: add it with --data-binary @file.")
|
|
@@ -127,20 +127,49 @@ class _TemplateNames(NamedTuple):
|
|
|
127
127
|
self.to_methods.update(other.to_methods)
|
|
128
128
|
|
|
129
129
|
|
|
130
|
-
def _receiver(node: ast.expr) ->
|
|
131
|
-
"""The name a method's object is reached from (``helper`` for
|
|
130
|
+
def _receiver(node: ast.expr) -> ast.Name | None:
|
|
131
|
+
"""The name node a method's object is reached from (``helper`` for
|
|
132
132
|
``helper.api.ids``, ``helper().ids``, ``helper['x'].ids``), or None for an
|
|
133
133
|
object written in place (``', '.join``)."""
|
|
134
134
|
while True:
|
|
135
135
|
match node:
|
|
136
136
|
case ast.Attribute(value=inner) | ast.Subscript(value=inner) | ast.Call(func=inner):
|
|
137
137
|
node = inner
|
|
138
|
-
case ast.Name(
|
|
139
|
-
return
|
|
138
|
+
case ast.Name():
|
|
139
|
+
return node
|
|
140
140
|
case _:
|
|
141
141
|
return None
|
|
142
142
|
|
|
143
143
|
|
|
144
|
+
def _local_comprehension_reads(tree: ast.expr) -> set[int]:
|
|
145
|
+
"""The name nodes read from comprehension targets, rather than context.
|
|
146
|
+
|
|
147
|
+
A generator's iterable is evaluated before its target is bound. The
|
|
148
|
+
target is visible in its filters, later generators and result, but not in
|
|
149
|
+
an expression outside the comprehension. Keep this walk iterative as the
|
|
150
|
+
other expression walks are: valid expressions can be deeply nested.
|
|
151
|
+
"""
|
|
152
|
+
local_reads: set[int] = set()
|
|
153
|
+
pending: list[tuple[ast.AST, frozenset[str]]] = [(tree, frozenset())]
|
|
154
|
+
while pending:
|
|
155
|
+
node, bound = pending.pop()
|
|
156
|
+
if isinstance(node, ast.Name):
|
|
157
|
+
if isinstance(node.ctx, ast.Load) and node.id in bound:
|
|
158
|
+
local_reads.add(id(node))
|
|
159
|
+
elif isinstance(node, ast.ListComp | ast.GeneratorExp | ast.DictComp):
|
|
160
|
+
for generator in node.generators:
|
|
161
|
+
pending.append((generator.iter, bound))
|
|
162
|
+
bound |= frozenset(name.id for name in ast.walk(generator.target) if isinstance(name, ast.Name))
|
|
163
|
+
pending.extend((condition, bound) for condition in generator.ifs)
|
|
164
|
+
if isinstance(node, ast.DictComp):
|
|
165
|
+
pending.extend(((node.key, bound), (node.value, bound)))
|
|
166
|
+
else:
|
|
167
|
+
pending.append((node.elt, bound))
|
|
168
|
+
else:
|
|
169
|
+
pending.extend((child, bound) for child in ast.iter_child_nodes(node))
|
|
170
|
+
return local_reads
|
|
171
|
+
|
|
172
|
+
|
|
144
173
|
def _extract_names_from_expr(expr: str) -> _TemplateNames:
|
|
145
174
|
"""Free identifiers a Python expression reads, and those it calls.
|
|
146
175
|
|
|
@@ -170,16 +199,16 @@ def _extract_names_from_expr(expr: str) -> _TemplateNames:
|
|
|
170
199
|
except TemplatesError:
|
|
171
200
|
return names
|
|
172
201
|
|
|
173
|
-
|
|
174
|
-
|
|
202
|
+
local_reads = _local_comprehension_reads(tree)
|
|
203
|
+
# simpleeval calls a bare name through its function table, even where a
|
|
204
|
+
# comprehension target of that name is bound as a value.
|
|
205
|
+
callees = {id(node.func) for node in ast.walk(tree) if isinstance(node, ast.Call) and isinstance(node.func, ast.Name)}
|
|
175
206
|
# What each argument that may be a function is handed to, by node.
|
|
176
207
|
keys: set[int] = set()
|
|
177
208
|
to_functions: set[int] = set()
|
|
178
209
|
to_methods: dict[int, str] = {}
|
|
179
210
|
for node in ast.walk(tree):
|
|
180
|
-
if isinstance(node, ast.
|
|
181
|
-
bound |= {n.id for n in ast.walk(node.target) if isinstance(n, ast.Name)}
|
|
182
|
-
elif isinstance(node, ast.Call):
|
|
211
|
+
if isinstance(node, ast.Call):
|
|
183
212
|
key = [keyword.value for keyword in node.keywords if keyword.arg == "key"]
|
|
184
213
|
others = [*node.args, *(keyword.value for keyword in node.keywords if keyword.arg != "key")]
|
|
185
214
|
match node.func:
|
|
@@ -189,22 +218,22 @@ def _extract_names_from_expr(expr: str) -> _TemplateNames:
|
|
|
189
218
|
keys.update(id(argument) for argument in key)
|
|
190
219
|
case ast.Attribute(value=value):
|
|
191
220
|
keys.update(id(argument) for argument in key)
|
|
192
|
-
if (receiver := _receiver(value)) is not None:
|
|
193
|
-
to_methods.update(dict.fromkeys(map(id, others), receiver))
|
|
194
|
-
if isinstance(node.func, ast.Name):
|
|
195
|
-
callees.add(id(node.func))
|
|
221
|
+
if (receiver := _receiver(value)) is not None and (id(receiver) not in local_reads or id(receiver) in callees):
|
|
222
|
+
to_methods.update(dict.fromkeys(map(id, others), receiver.id))
|
|
196
223
|
|
|
197
224
|
for node in ast.walk(tree):
|
|
198
|
-
if isinstance(node, ast.Name) and isinstance(node.ctx, ast.Load)
|
|
225
|
+
if isinstance(node, ast.Name) and isinstance(node.ctx, ast.Load):
|
|
199
226
|
if id(node) in callees:
|
|
200
227
|
names.called.add(node.id)
|
|
201
228
|
continue
|
|
229
|
+
if id(node) in local_reads:
|
|
230
|
+
continue
|
|
202
231
|
names.read.add(node.id)
|
|
203
232
|
if id(node) in keys:
|
|
204
233
|
names.keys.add(node.id)
|
|
205
234
|
elif id(node) in to_functions:
|
|
206
235
|
names.to_functions.add(node.id)
|
|
207
|
-
elif (receiver := to_methods.get(id(node))) is not None
|
|
236
|
+
elif (receiver := to_methods.get(id(node))) is not None:
|
|
208
237
|
names.to_methods.add((receiver, node.id))
|
|
209
238
|
else:
|
|
210
239
|
names.loose.add(node.id)
|
{pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/templates/substitution.py
RENAMED
|
@@ -133,7 +133,7 @@ class _KeyDoesNotExist(InvalidExpression):
|
|
|
133
133
|
|
|
134
134
|
def __init__(self, key: object, expression: str):
|
|
135
135
|
self.message = f"Key {key!r} does not exist in expression '{expression}'"
|
|
136
|
-
super(
|
|
136
|
+
super().__init__(self.message)
|
|
137
137
|
|
|
138
138
|
|
|
139
139
|
class _MethodNotCalled(AttributeDoesNotExist):
|
|
@@ -462,11 +462,20 @@ def _any_string(obj: Any, predicate: Callable[[str], bool]) -> bool:
|
|
|
462
462
|
"""True when ``predicate`` holds for any string anywhere in the structure.
|
|
463
463
|
|
|
464
464
|
Iterative on purpose: a recursive walk spent two stack frames per level of
|
|
465
|
-
nesting, so a value a few hundred levels deep overflowed it.
|
|
465
|
+
nesting, so a value a few hundred levels deep overflowed it. Track objects
|
|
466
|
+
already visited so a fixture's cyclic container cannot loop forever.
|
|
466
467
|
"""
|
|
467
468
|
pending = [obj]
|
|
469
|
+
# Keep the objects alive while scanning: a set of IDs alone could confuse
|
|
470
|
+
# a newly dumped model with an earlier object whose ID was reused.
|
|
471
|
+
seen: dict[int, Any] = {}
|
|
468
472
|
while pending:
|
|
469
|
-
|
|
473
|
+
current = pending.pop()
|
|
474
|
+
if isinstance(current, dict | list | tuple | BaseModel | SimpleNamespace):
|
|
475
|
+
if id(current) in seen:
|
|
476
|
+
continue
|
|
477
|
+
seen[id(current)] = current
|
|
478
|
+
match current:
|
|
470
479
|
case str() as text:
|
|
471
480
|
if predicate(text):
|
|
472
481
|
return True
|
|
@@ -46,10 +46,10 @@ def import_function(name: str, *, quoted: bool = True) -> Callable[..., Any]:
|
|
|
46
46
|
raise UserFunctionError(f"importing its module raised {type(e).__name__}") from None
|
|
47
47
|
raise UserFunctionError(f"Failed to import module '{module_path}': {e}") from e
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
try:
|
|
50
|
+
func = getattr(module, function_name)
|
|
51
|
+
except AttributeError:
|
|
52
|
+
raise UserFunctionError(f"Function '{function_name}' not found in module '{module_path}'" if quoted else "its module has no function of that name") from None
|
|
53
53
|
if not callable(func):
|
|
54
54
|
raise UserFunctionError(f"'{module_path}:{function_name}' is not callable" if quoted else "what it names is not callable")
|
|
55
55
|
|
|
@@ -186,12 +186,16 @@ def _signature_problems(func: Any, provided: set[str]) -> Iterator[tuple[Diagnos
|
|
|
186
186
|
|
|
187
187
|
params = list(signature.parameters.values())
|
|
188
188
|
keyword_acceptable = {p.name for p in params if p.kind in (p.POSITIONAL_OR_KEYWORD, p.KEYWORD_ONLY)}
|
|
189
|
-
|
|
189
|
+
required_keywords = {p.name for p in params if p.default is p.empty and p.kind in (p.POSITIONAL_OR_KEYWORD, p.KEYWORD_ONLY)}
|
|
190
|
+
required_positionals = {p.name for p in params if p.default is p.empty and p.kind is p.POSITIONAL_ONLY}
|
|
190
191
|
|
|
191
192
|
if not any(p.kind is p.VAR_KEYWORD for p in params):
|
|
192
193
|
for name in sorted(provided - keyword_acceptable):
|
|
193
194
|
yield DiagnosticCode.UNKNOWN_ARG, f"unexpected argument '{name}'"
|
|
194
|
-
|
|
195
|
+
# A keyword with the same name cannot fill a positional-only parameter.
|
|
196
|
+
# With **kwargs it is accepted into kwargs, but the positional argument is
|
|
197
|
+
# still missing when the function is called.
|
|
198
|
+
for name in sorted(required_positionals | (required_keywords - provided)):
|
|
195
199
|
yield DiagnosticCode.MISSING_ARG, f"missing required argument '{name}'"
|
|
196
200
|
|
|
197
201
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/importers/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/jsonref/__init__.py
RENAMED
|
File without changes
|
{pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/jsonref/equality.py
RENAMED
|
File without changes
|
{pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/jsonref/exceptions.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/templates/__init__.py
RENAMED
|
File without changes
|
{pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/templates/exceptions.py
RENAMED
|
File without changes
|
{pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/templates/expressions.py
RENAMED
|
File without changes
|
{pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/templates/functions.py
RENAMED
|
File without changes
|
|
File without changes
|
{pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/validation/__init__.py
RENAMED
|
File without changes
|
{pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/validation/diagnostics.py
RENAMED
|
File without changes
|
{pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/validation/discovery.py
RENAMED
|
File without changes
|
{pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/validation/loader.py
RENAMED
|
File without changes
|
{pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/validation/semantic.py
RENAMED
|
File without changes
|
{pytest_httpchain-0.17.0 → pytest_httpchain-0.17.1}/src/pytest_httpchain/validation/validate.py
RENAMED
|
File without changes
|
|
File without changes
|