schemathesis 4.0.5__py3-none-any.whl → 4.0.7__py3-none-any.whl
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.
- schemathesis/cli/commands/run/handlers/junitxml.py +1 -1
- schemathesis/cli/commands/run/handlers/output.py +0 -1
- schemathesis/core/deserialization.py +14 -0
- schemathesis/core/media_types.py +1 -1
- schemathesis/engine/phases/probes.py +2 -3
- schemathesis/specs/openapi/schemas.py +19 -6
- {schemathesis-4.0.5.dist-info → schemathesis-4.0.7.dist-info}/METADATA +1 -1
- {schemathesis-4.0.5.dist-info → schemathesis-4.0.7.dist-info}/RECORD +11 -11
- {schemathesis-4.0.5.dist-info → schemathesis-4.0.7.dist-info}/WHEEL +0 -0
- {schemathesis-4.0.5.dist-info → schemathesis-4.0.7.dist-info}/entry_points.txt +0 -0
- {schemathesis-4.0.5.dist-info → schemathesis-4.0.7.dist-info}/licenses/LICENSE +0 -0
@@ -41,7 +41,7 @@ class JunitXMLHandler(EventHandler):
|
|
41
41
|
TestSuite("schemathesis", test_cases=list(self.test_cases.values()), hostname=platform.node())
|
42
42
|
]
|
43
43
|
with open(self.path, "w") as fd:
|
44
|
-
to_xml_report_file(file_descriptor=fd, test_suites=test_suites, prettyprint=True)
|
44
|
+
to_xml_report_file(file_descriptor=fd, test_suites=test_suites, prettyprint=True, encoding="utf-8")
|
45
45
|
|
46
46
|
def get_or_create_test_case(self, label: str) -> TestCase:
|
47
47
|
return self.test_cases.setdefault(label, TestCase(label, elapsed_sec=0.0, allow_multiple_subelements=True))
|
@@ -955,7 +955,6 @@ class OutputHandler(EventHandler):
|
|
955
955
|
ProbeOutcome.SUCCESS: ("✓", Style(color="green")),
|
956
956
|
ProbeOutcome.FAILURE: ("✘", Style(color="red")),
|
957
957
|
ProbeOutcome.SKIP: ("⊘", Style(color="yellow")),
|
958
|
-
ProbeOutcome.ERROR: ("⚠", Style(color="yellow")),
|
959
958
|
}[probe_run.outcome]
|
960
959
|
|
961
960
|
table.add_row(f"{probe_run.probe.name}:", Text(icon, style=style))
|
@@ -4,6 +4,9 @@ import re
|
|
4
4
|
from functools import lru_cache
|
5
5
|
from typing import TYPE_CHECKING, Any, BinaryIO, TextIO
|
6
6
|
|
7
|
+
from schemathesis.core import media_types
|
8
|
+
from schemathesis.core.transport import Response
|
9
|
+
|
7
10
|
if TYPE_CHECKING:
|
8
11
|
import yaml
|
9
12
|
|
@@ -63,3 +66,14 @@ def deserialize_yaml(stream: str | bytes | TextIO | BinaryIO) -> Any:
|
|
63
66
|
import yaml
|
64
67
|
|
65
68
|
return yaml.load(stream, get_yaml_loader())
|
69
|
+
|
70
|
+
|
71
|
+
def deserialize_response(response: Response, content_type: str) -> Any:
|
72
|
+
if media_types.is_yaml(content_type):
|
73
|
+
encoding = response.encoding or "utf-8"
|
74
|
+
return deserialize_yaml(response.content.decode(encoding))
|
75
|
+
if media_types.is_json(content_type):
|
76
|
+
return response.json()
|
77
|
+
raise NotImplementedError(
|
78
|
+
f"Unsupported Content-Type: {content_type!r}. Supported types are: application/yaml, application/json."
|
79
|
+
)
|
schemathesis/core/media_types.py
CHANGED
@@ -55,7 +55,7 @@ def is_json(value: str) -> bool:
|
|
55
55
|
|
56
56
|
def is_yaml(value: str) -> bool:
|
57
57
|
"""Detect whether the content type is YAML-compatible."""
|
58
|
-
return value in ("text/yaml", "text/x-yaml", "application/x-yaml", "text/vnd.yaml")
|
58
|
+
return value in ("text/yaml", "text/x-yaml", "application/x-yaml", "text/vnd.yaml", "application/yaml")
|
59
59
|
|
60
60
|
|
61
61
|
def is_plain_text(value: str) -> bool:
|
@@ -86,8 +86,6 @@ class ProbeOutcome(str, enum.Enum):
|
|
86
86
|
FAILURE = "failure"
|
87
87
|
# Probe is not applicable
|
88
88
|
SKIP = "skip"
|
89
|
-
# Error occurred during the probe
|
90
|
-
ERROR = "error"
|
91
89
|
|
92
90
|
|
93
91
|
@dataclass
|
@@ -166,7 +164,8 @@ def send(probe: Probe, ctx: EngineContext) -> ProbeRun:
|
|
166
164
|
# which is not currently implemented
|
167
165
|
return ProbeRun(probe, ProbeOutcome.SKIP, None, None, None)
|
168
166
|
except RequestException as exc:
|
167
|
+
# Consider any network errors as a failed probe
|
169
168
|
req = exc.request if isinstance(exc.request, PreparedRequest) else None
|
170
|
-
return ProbeRun(probe, ProbeOutcome.
|
169
|
+
return ProbeRun(probe, ProbeOutcome.FAILURE, req, None, exc)
|
171
170
|
result_type = probe.analyze_response(response)
|
172
171
|
return ProbeRun(probe, result_type, request, response)
|
@@ -29,7 +29,7 @@ from requests.exceptions import InvalidHeader
|
|
29
29
|
from requests.structures import CaseInsensitiveDict
|
30
30
|
from requests.utils import check_header_validity
|
31
31
|
|
32
|
-
from schemathesis.core import NOT_SET, NotSet, Specification, media_types
|
32
|
+
from schemathesis.core import NOT_SET, NotSet, Specification, deserialization, media_types
|
33
33
|
from schemathesis.core.compat import RefResolutionError
|
34
34
|
from schemathesis.core.errors import InternalError, InvalidSchema, LoaderError, LoaderErrorKind, OperationNotFound
|
35
35
|
from schemathesis.core.failures import Failure, FailureGroup, MalformedJson
|
@@ -617,17 +617,30 @@ class BaseOpenAPISchema(BaseSchema):
|
|
617
617
|
formatted_content_types = [f"\n- `{content_type}`" for content_type in all_media_types]
|
618
618
|
message = f"The following media types are documented in the schema:{''.join(formatted_content_types)}"
|
619
619
|
failures.append(MissingContentType(operation=operation.label, message=message, media_types=all_media_types))
|
620
|
-
|
620
|
+
# Default content type
|
621
|
+
content_type = "application/json"
|
621
622
|
else:
|
622
623
|
content_type = content_types[0]
|
623
|
-
if content_type and not media_types.is_json(content_type):
|
624
|
-
_maybe_raise_one_or_more(failures)
|
625
|
-
return None
|
626
624
|
try:
|
627
|
-
data =
|
625
|
+
data = deserialization.deserialize_response(response, content_type)
|
628
626
|
except JSONDecodeError as exc:
|
629
627
|
failures.append(MalformedJson.from_exception(operation=operation.label, exc=exc))
|
630
628
|
_maybe_raise_one_or_more(failures)
|
629
|
+
return None
|
630
|
+
except NotImplementedError:
|
631
|
+
# If the content type is not supported, we cannot validate it
|
632
|
+
_maybe_raise_one_or_more(failures)
|
633
|
+
return None
|
634
|
+
except Exception as exc:
|
635
|
+
failures.append(
|
636
|
+
Failure(
|
637
|
+
operation=operation.label,
|
638
|
+
title="Content deserialization error",
|
639
|
+
message=f"Failed to deserialize response content:\n\n {exc}",
|
640
|
+
)
|
641
|
+
)
|
642
|
+
_maybe_raise_one_or_more(failures)
|
643
|
+
return None
|
631
644
|
with self._validating_response(scopes) as resolver:
|
632
645
|
try:
|
633
646
|
jsonschema.validate(
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: schemathesis
|
3
|
-
Version: 4.0.
|
3
|
+
Version: 4.0.7
|
4
4
|
Summary: Property-based testing framework for Open API and GraphQL based apps
|
5
5
|
Project-URL: Documentation, https://schemathesis.readthedocs.io/en/stable/
|
6
6
|
Project-URL: Changelog, https://github.com/schemathesis/schemathesis/blob/master/CHANGELOG.md
|
@@ -22,8 +22,8 @@ schemathesis/cli/commands/run/validation.py,sha256=FzCzYdW1-hn3OgyzPO1p6wHEX5PG7
|
|
22
22
|
schemathesis/cli/commands/run/handlers/__init__.py,sha256=TPZ3KdGi8m0fjlN0GjA31MAXXn1qI7uU4FtiDwroXZI,1915
|
23
23
|
schemathesis/cli/commands/run/handlers/base.py,sha256=yDsTtCiztLksfk7cRzg8JlaAVOfS-zwK3tsJMOXAFyc,530
|
24
24
|
schemathesis/cli/commands/run/handlers/cassettes.py,sha256=rRD4byjp4HXCkJS-zx3jSIFOJsPq77ejPpYeyCtsEZs,19461
|
25
|
-
schemathesis/cli/commands/run/handlers/junitxml.py,sha256=
|
26
|
-
schemathesis/cli/commands/run/handlers/output.py,sha256=
|
25
|
+
schemathesis/cli/commands/run/handlers/junitxml.py,sha256=3KylA3wDBzpGjUhQnNIT6rfCo_8uh29epcUOY5bHHzQ,2568
|
26
|
+
schemathesis/cli/commands/run/handlers/output.py,sha256=IRERu8Mir3yi5BgDf40SFwYQbxd0aTrWE9IRkjdO7h4,62808
|
27
27
|
schemathesis/cli/ext/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
28
28
|
schemathesis/cli/ext/fs.py,sha256=3lvoAsEDDdih75ITJJNxemd3nwxX55gGWrI7uDxm0cM,447
|
29
29
|
schemathesis/cli/ext/groups.py,sha256=kQ37t6qeArcKaY2y5VxyK3_KwAkBKCVm58IYV8gewds,2720
|
@@ -50,7 +50,7 @@ schemathesis/core/__init__.py,sha256=j862XBH5dXhxsrDg9mE7n4cSSfol0EHdY0ru1d27tCc
|
|
50
50
|
schemathesis/core/compat.py,sha256=9BWCrFoqN2sJIaiht_anxe8kLjYMR7t0iiOkXqLRUZ8,1058
|
51
51
|
schemathesis/core/control.py,sha256=IzwIc8HIAEMtZWW0Q0iXI7T1niBpjvcLlbuwOSmy5O8,130
|
52
52
|
schemathesis/core/curl.py,sha256=yuaCe_zHLGwUjEeloQi6W3tOA3cGdnHDNI17-5jia0o,1723
|
53
|
-
schemathesis/core/deserialization.py,sha256=
|
53
|
+
schemathesis/core/deserialization.py,sha256=qjXUPaz_mc1OSgXzTUSkC8tuVR8wgVQtb9g3CcAF6D0,2951
|
54
54
|
schemathesis/core/errors.py,sha256=KuFLy5ZOGn8KlD4ai5HK_WFlB3fJ2rSKwV1yD4fn4BU,16295
|
55
55
|
schemathesis/core/failures.py,sha256=MYyRnom-XeUEuBmq2ffdz34xhxmpSHWaQunfHtliVsY,8932
|
56
56
|
schemathesis/core/fs.py,sha256=ItQT0_cVwjDdJX9IiI7EnU75NI2H3_DCEyyUjzg_BgI,472
|
@@ -58,7 +58,7 @@ schemathesis/core/hooks.py,sha256=qhbkkRSf8URJ4LKv2wmKRINKpquUOgxQzWBHKWRWo3Q,47
|
|
58
58
|
schemathesis/core/lazy_import.py,sha256=aMhWYgbU2JOltyWBb32vnWBb6kykOghucEzI_F70yVE,470
|
59
59
|
schemathesis/core/loaders.py,sha256=SQQ-8m64-D2FaOgvwKZLyTtLJuzP3RPo7Ud2BERK1c0,3404
|
60
60
|
schemathesis/core/marks.py,sha256=SH7jsVuNRJjx2gZN9Ze5MY01u7FJiHeO0iruzKi5rm4,2135
|
61
|
-
schemathesis/core/media_types.py,sha256=
|
61
|
+
schemathesis/core/media_types.py,sha256=ThdAikBttdRD1RB9-83rMmtG_z-BdW8xidUxzhgdUqI,2168
|
62
62
|
schemathesis/core/rate_limit.py,sha256=7tg9Znk11erTfw8-ANutjEmu7hbfUHZx_iEdkoaP174,1757
|
63
63
|
schemathesis/core/registries.py,sha256=T4jZB4y3zBHdeSgQc0pRbgSeMblvO-6z4I3zmzIfTi0,811
|
64
64
|
schemathesis/core/result.py,sha256=d449YvyONjqjDs-A5DAPgtAI96iT753K8sU6_1HLo2Q,461
|
@@ -76,7 +76,7 @@ schemathesis/engine/errors.py,sha256=HRtFFg-TQ68VmGAM3p6VLOimTU7VaFnv6iKD9-ucjaw
|
|
76
76
|
schemathesis/engine/events.py,sha256=VV6epicFIJnX4c87fVNSd0ibDccX3gryDv52OUGa3FI,6370
|
77
77
|
schemathesis/engine/recorder.py,sha256=K3HfMARrT5mPWXPnYebjjcq5CcsBRhMrtZwEL9_Lvtg,8432
|
78
78
|
schemathesis/engine/phases/__init__.py,sha256=jUIfb_9QoUo4zmJEVU0z70PgXPYjt8CIqp4qP_HlYHg,3146
|
79
|
-
schemathesis/engine/phases/probes.py,sha256=
|
79
|
+
schemathesis/engine/phases/probes.py,sha256=zvK-uLjVXpvaQ89hNq73WRH_OiIHRWvhvnOkx_C8Iq0,5678
|
80
80
|
schemathesis/engine/phases/stateful/__init__.py,sha256=Lz1rgNqCfUSIz173XqCGsiMuUI5bh4L-RIFexU1-c_Q,2461
|
81
81
|
schemathesis/engine/phases/stateful/_executor.py,sha256=_303Yqflx1iFNTQI2EfjSp_2T21YvzJJgMSazhpv5JQ,15200
|
82
82
|
schemathesis/engine/phases/stateful/context.py,sha256=A7X1SLDOWFpCvFN9IiIeNVZM0emjqatmJL_k9UsO7vM,2946
|
@@ -134,7 +134,7 @@ schemathesis/specs/openapi/media_types.py,sha256=F5M6TKl0s6Z5X8mZpPsWDEdPBvxclKR
|
|
134
134
|
schemathesis/specs/openapi/parameters.py,sha256=BevME4DWLQ-OFvc_7fREMjj99VAbVNxVb5i8OEX6Pfs,14453
|
135
135
|
schemathesis/specs/openapi/patterns.py,sha256=cBj8W4wn7VLJd4nABaIH5f502-zBDiqljxLgPWUn-50,15609
|
136
136
|
schemathesis/specs/openapi/references.py,sha256=40YcDExPLR2B8EOwt-Csw-5MYFi2xj_DXf91J0Pc9d4,8855
|
137
|
-
schemathesis/specs/openapi/schemas.py,sha256=
|
137
|
+
schemathesis/specs/openapi/schemas.py,sha256=4bL-nOFOykfOGHbkmUor9MnCqhAzW5S5oIQbL36wvVc,51972
|
138
138
|
schemathesis/specs/openapi/security.py,sha256=6UWYMhL-dPtkTineqqBFNKca1i4EuoTduw-EOLeE0aQ,7149
|
139
139
|
schemathesis/specs/openapi/serialization.py,sha256=VdDLmeHqxlWM4cxQQcCkvrU6XurivolwEEaT13ohelA,11972
|
140
140
|
schemathesis/specs/openapi/utils.py,sha256=ER4vJkdFVDIE7aKyxyYatuuHVRNutytezgE52pqZNE8,900
|
@@ -157,8 +157,8 @@ schemathesis/transport/prepare.py,sha256=iiB8KTAqnnuqjWzblIPiGVdkGIF7Yr1SAEz-KZz
|
|
157
157
|
schemathesis/transport/requests.py,sha256=rziZTrZCVMAqgy6ldB8iTwhkpAsnjKSgK8hj5Sq3ThE,10656
|
158
158
|
schemathesis/transport/serialization.py,sha256=igUXKZ_VJ9gV7P0TUc5PDQBJXl_s0kK9T3ljGWWvo6E,10339
|
159
159
|
schemathesis/transport/wsgi.py,sha256=KoAfvu6RJtzyj24VGB8e-Iaa9smpgXJ3VsM8EgAz2tc,6152
|
160
|
-
schemathesis-4.0.
|
161
|
-
schemathesis-4.0.
|
162
|
-
schemathesis-4.0.
|
163
|
-
schemathesis-4.0.
|
164
|
-
schemathesis-4.0.
|
160
|
+
schemathesis-4.0.7.dist-info/METADATA,sha256=FwIP6I23WtilfbZgzNA4ZSs8FnGWexKmi08G1m5h8Co,8471
|
161
|
+
schemathesis-4.0.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
162
|
+
schemathesis-4.0.7.dist-info/entry_points.txt,sha256=hiK3un-xfgPdwj9uj16YVDtTNpO128bmk0U82SMv8ZQ,152
|
163
|
+
schemathesis-4.0.7.dist-info/licenses/LICENSE,sha256=2Ve4J8v5jMQAWrT7r1nf3bI8Vflk3rZVQefiF2zpxwg,1121
|
164
|
+
schemathesis-4.0.7.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|