pytest-httpchain 0.18.0__tar.gz → 0.18.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.
Files changed (55) hide show
  1. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/PKG-INFO +1 -1
  2. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/pyproject.toml +1 -1
  3. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/pyproject.toml.orig +1 -1
  4. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/models/entities.py +29 -4
  5. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/request_builder.py +35 -1
  6. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/LICENSE +0 -0
  7. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/README.md +0 -0
  8. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/__init__.py +0 -0
  9. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/body_schema.py +0 -0
  10. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/carrier.py +0 -0
  11. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/cli.py +0 -0
  12. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/constants.py +0 -0
  13. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/dataflow.py +0 -0
  14. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/errors.py +0 -0
  15. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/factory.py +0 -0
  16. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/har_writer.py +0 -0
  17. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/importers/__init__.py +0 -0
  18. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/importers/builder.py +0 -0
  19. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/importers/curl.py +0 -0
  20. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/importers/har.py +0 -0
  21. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/jsonref/__init__.py +0 -0
  22. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/jsonref/equality.py +0 -0
  23. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/jsonref/exceptions.py +0 -0
  24. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/jsonref/jsonc.py +0 -0
  25. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/jsonref/loader.py +0 -0
  26. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/jsonref/plumbing/__init__.py +0 -0
  27. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/jsonref/plumbing/circular.py +0 -0
  28. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/jsonref/plumbing/path.py +0 -0
  29. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/jsonref/plumbing/reference.py +0 -0
  30. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/models/__init__.py +0 -0
  31. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/models/types.py +0 -0
  32. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/parallel_stats.py +0 -0
  33. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/plugin.py +0 -0
  34. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/py.typed +0 -0
  35. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/redaction.py +0 -0
  36. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/report_formatter.py +0 -0
  37. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/response_steps.py +0 -0
  38. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/schema.py +0 -0
  39. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/scoping.py +0 -0
  40. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/templates/__init__.py +0 -0
  41. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/templates/exceptions.py +0 -0
  42. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/templates/expressions.py +0 -0
  43. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/templates/functions.py +0 -0
  44. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/templates/substitution.py +0 -0
  45. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/userfunc.py +0 -0
  46. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/utils.py +0 -0
  47. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/validation/__init__.py +0 -0
  48. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/validation/deep.py +0 -0
  49. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/validation/diagnostics.py +0 -0
  50. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/validation/discovery.py +0 -0
  51. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/validation/loader.py +0 -0
  52. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/validation/semantic.py +0 -0
  53. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/validation/validate.py +0 -0
  54. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/warnings.py +0 -0
  55. {pytest_httpchain-0.18.0 → pytest_httpchain-0.18.1}/src/pytest_httpchain/wire_codec.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pytest-httpchain
3
- Version: 0.18.0
3
+ Version: 0.18.1
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
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "pytest-httpchain"
3
- version = "0.18.0"
3
+ version = "0.18.1"
4
4
  description = "pytest plugin for HTTP testing using JSON files"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.13"
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "pytest-httpchain"
3
- version = "0.18.0"
3
+ version = "0.18.1"
4
4
  description = "pytest plugin for HTTP testing using JSON files"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.13"
@@ -26,13 +26,19 @@ from pydantic import (
26
26
  PositiveFloat,
27
27
  PositiveInt,
28
28
  RootModel,
29
+ Strict,
30
+ StrictBool,
29
31
  StrictBytes,
32
+ StrictFloat,
33
+ StrictInt,
34
+ StrictStr,
30
35
  Tag,
31
36
  TypeAdapter,
32
37
  ValidationError,
33
38
  ValidationInfo,
34
39
  ValidatorFunctionWrapHandler,
35
40
  WithJsonSchema,
41
+ WrapValidator,
36
42
  model_validator,
37
43
  )
38
44
  from pydantic.json_schema import JsonDict
@@ -847,9 +853,28 @@ class HeaderMatcher(StrictModel):
847
853
  return self
848
854
 
849
855
 
850
- # An operand compared as JSON. A template over `vars` renders an object as a
851
- # SimpleNamespace, which stands for the object it was written as.
852
- _JsonOperand = Annotated[JsonValue | bytes, BeforeValidator(convert_namespace_to_dict)]
856
+ # JSON's own validator keeps its exact rules for byte-free operands. If it
857
+ # rejects nested MessagePack bin values, this strict recursive form accepts
858
+ # those without admitting tuples or other values JSON itself would reject.
859
+ type BinaryStructuredValue = (
860
+ StrictStr | StrictBool | StrictInt | StrictFloat | StrictBytes | None | Annotated[list[BinaryStructuredValue], Strict()] | Annotated[dict[str, BinaryStructuredValue], Strict()]
861
+ )
862
+ _BINARY_STRUCTURED = TypeAdapter(BinaryStructuredValue)
863
+
864
+
865
+ def _allow_nested_bytes(value: Any, handler: ValidatorFunctionWrapHandler) -> Any:
866
+ try:
867
+ return handler(value)
868
+ except ValidationError as original:
869
+ try:
870
+ return _BINARY_STRUCTURED.validate_python(value)
871
+ except ValidationError:
872
+ raise original from None
873
+
874
+
875
+ # A template over `vars` renders an object as a SimpleNamespace, which stands
876
+ # for the object it was written as.
877
+ _JsonOperand = Annotated[JsonValue | bytes, BeforeValidator(convert_namespace_to_dict), WrapValidator(_allow_nested_bytes)]
853
878
 
854
879
 
855
880
  def _operand_schema(schema: JsonDict) -> None:
@@ -978,7 +1003,7 @@ def _declared_value(v: Any) -> Any:
978
1003
  # A value compared by JSON equality: anything but an object, which is a matcher.
979
1004
  # The schema says so, so an editor holds a literal object to the matcher's keys.
980
1005
  _JsonEqualityValue = Annotated[
981
- JsonValue | bytes,
1006
+ Annotated[JsonValue | bytes, WrapValidator(_allow_nested_bytes)],
982
1007
  WithJsonSchema({"type": ["string", "number", "boolean", "null", "array"], "description": "Equal to this JSON value (true is not 1; 1 equals 1.0)."}),
983
1008
  ]
984
1009
 
@@ -520,6 +520,34 @@ def _encode_param(key: str, value: Any) -> str:
520
520
  raise RequestError(f"Cannot convert query parameter '{key}' to text: {type(e).__name__}: {e}") from e
521
521
 
522
522
 
523
+ def _encoded_binary_form(data: Mapping[str, Any]) -> bytes | None:
524
+ """URL-encode form data ourselves only when a field holds bytes.
525
+
526
+ httpx stringifies bytes in ``data=``, losing the packet. For forms without
527
+ bytes, its own encoder remains in use. Its scalar spellings and repeated
528
+ fields are kept here for the mixed binary/text case.
529
+ """
530
+ fields = [(key, item) for key, value in data.items() for item in (value if isinstance(value, list | tuple) else (value,))]
531
+ if not any(isinstance(value, bytes | bytearray) for _, value in fields):
532
+ return None
533
+
534
+ def scalar(value: Any) -> str | bytes:
535
+ if isinstance(value, bytes | bytearray):
536
+ return bytes(value)
537
+ if value is True:
538
+ return "true"
539
+ if value is False:
540
+ return "false"
541
+ if value is None:
542
+ return ""
543
+ return str(value)
544
+
545
+ try:
546
+ return urlencode([(key, scalar(value)) for key, value in fields]).encode("ascii")
547
+ except Exception as e:
548
+ raise RequestError(f"Cannot encode form data: {type(e).__name__}: {e}") from e
549
+
550
+
523
551
  def _merge_query(query: str, params: dict[str, Any], defaults: Mapping[str, Any]) -> str:
524
552
  """The URL's raw ``query`` with ``params`` merged in, and ``defaults``
525
553
  (``client.params``) for the keys neither sets.
@@ -655,7 +683,13 @@ def build_request_kwargs(
655
683
  request_kwargs["json"] = {"query": gql.query, "variables": gql.variables}
656
684
 
657
685
  case FormBody(form=data):
658
- request_kwargs["data"] = data
686
+ encoded = _encoded_binary_form(data)
687
+ if encoded is None:
688
+ request_kwargs["data"] = data
689
+ else:
690
+ request_kwargs["content"] = encoded
691
+ if not _declares_content_type(request_model.headers):
692
+ request_kwargs["headers"] = {**request_model.headers, "Content-Type": "application/x-www-form-urlencoded"}
659
693
  if data:
660
694
  body_content_type = "application/x-www-form-urlencoded"
661
695