schemathesis 4.0.8__py3-none-any.whl → 4.0.9__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/output.py +7 -14
- schemathesis/engine/errors.py +10 -2
- schemathesis/engine/phases/probes.py +4 -9
- schemathesis/generation/coverage.py +14 -0
- schemathesis/generation/hypothesis/builder.py +22 -18
- {schemathesis-4.0.8.dist-info → schemathesis-4.0.9.dist-info}/METADATA +1 -1
- {schemathesis-4.0.8.dist-info → schemathesis-4.0.9.dist-info}/RECORD +10 -10
- {schemathesis-4.0.8.dist-info → schemathesis-4.0.9.dist-info}/WHEEL +0 -0
- {schemathesis-4.0.8.dist-info → schemathesis-4.0.9.dist-info}/entry_points.txt +0 -0
- {schemathesis-4.0.8.dist-info → schemathesis-4.0.9.dist-info}/licenses/LICENSE +0 -0
@@ -20,10 +20,9 @@ from schemathesis.config import ProjectConfig, ReportFormat, SchemathesisWarning
|
|
20
20
|
from schemathesis.core.errors import LoaderError, LoaderErrorKind, format_exception, split_traceback
|
21
21
|
from schemathesis.core.failures import MessageBlock, Severity, format_failures
|
22
22
|
from schemathesis.core.output import prepare_response_payload
|
23
|
-
from schemathesis.core.result import
|
23
|
+
from schemathesis.core.result import Ok
|
24
24
|
from schemathesis.core.version import SCHEMATHESIS_VERSION
|
25
25
|
from schemathesis.engine import Status, events
|
26
|
-
from schemathesis.engine.errors import EngineErrorInfo
|
27
26
|
from schemathesis.engine.phases import PhaseName, PhaseSkipReason
|
28
27
|
from schemathesis.engine.phases.probes import ProbeOutcome
|
29
28
|
from schemathesis.engine.recorder import Interaction, ScenarioRecorder
|
@@ -960,7 +959,9 @@ class OutputHandler(EventHandler):
|
|
960
959
|
table.add_row(f"{probe_run.probe.name}:", Text(icon, style=style))
|
961
960
|
|
962
961
|
message = Padding(table, BLOCK_PADDING)
|
963
|
-
|
962
|
+
else:
|
963
|
+
assert event.status == Status.SKIP
|
964
|
+
assert isinstance(event.payload, Ok)
|
964
965
|
message = Padding(
|
965
966
|
Text.assemble(
|
966
967
|
("⏭ ", ""),
|
@@ -968,17 +969,6 @@ class OutputHandler(EventHandler):
|
|
968
969
|
),
|
969
970
|
BLOCK_PADDING,
|
970
971
|
)
|
971
|
-
else:
|
972
|
-
assert event.status == Status.ERROR
|
973
|
-
assert isinstance(event.payload, Err)
|
974
|
-
error = EngineErrorInfo(event.payload.err())
|
975
|
-
message = Padding(
|
976
|
-
Text.assemble(
|
977
|
-
("🚫 ", ""),
|
978
|
-
(f"API probing failed: {error.message}", Style(color="red")),
|
979
|
-
),
|
980
|
-
BLOCK_PADDING,
|
981
|
-
)
|
982
972
|
self.console.print(message)
|
983
973
|
self.console.print()
|
984
974
|
elif phase.name == PhaseName.STATEFUL_TESTING and phase.is_enabled and self.stateful_tests_manager is not None:
|
@@ -1337,6 +1327,9 @@ class OutputHandler(EventHandler):
|
|
1337
1327
|
click.echo(_style("Test Phases:", bold=True))
|
1338
1328
|
|
1339
1329
|
for phase in PhaseName:
|
1330
|
+
if phase == PhaseName.PROBING:
|
1331
|
+
# It is not a test phase
|
1332
|
+
continue
|
1340
1333
|
status, skip_reason = self.phases[phase]
|
1341
1334
|
|
1342
1335
|
if status == Status.SKIP:
|
schemathesis/engine/errors.py
CHANGED
@@ -426,7 +426,15 @@ def is_unrecoverable_network_error(exc: Exception) -> bool:
|
|
426
426
|
|
427
427
|
def has_connection_reset(inner: BaseException) -> bool:
|
428
428
|
exc_str = str(inner)
|
429
|
-
if any(
|
429
|
+
if any(
|
430
|
+
pattern in exc_str
|
431
|
+
for pattern in [
|
432
|
+
"Connection reset by peer",
|
433
|
+
"[Errno 104]",
|
434
|
+
"ECONNRESET",
|
435
|
+
"An established connection was aborted",
|
436
|
+
]
|
437
|
+
):
|
430
438
|
return True
|
431
439
|
|
432
440
|
if inner.__context__ is not None:
|
@@ -434,7 +442,7 @@ def is_unrecoverable_network_error(exc: Exception) -> bool:
|
|
434
442
|
|
435
443
|
return False
|
436
444
|
|
437
|
-
if isinstance(exc, requests.Timeout):
|
445
|
+
if isinstance(exc, (requests.Timeout, requests.exceptions.ChunkedEncodingError)):
|
438
446
|
return True
|
439
447
|
if isinstance(exc.__context__, ProtocolError):
|
440
448
|
if len(exc.__context__.args) == 2 and isinstance(exc.__context__.args[1], RemoteDisconnected):
|
@@ -13,7 +13,7 @@ import warnings
|
|
13
13
|
from dataclasses import dataclass
|
14
14
|
from typing import TYPE_CHECKING
|
15
15
|
|
16
|
-
from schemathesis.core.result import
|
16
|
+
from schemathesis.core.result import Ok, Result
|
17
17
|
from schemathesis.core.transport import USER_AGENT
|
18
18
|
from schemathesis.engine import Status, events
|
19
19
|
from schemathesis.transport.prepare import get_default_headers
|
@@ -41,16 +41,11 @@ def execute(ctx: EngineContext, phase: Phase) -> EventGenerator:
|
|
41
41
|
payload: Result[ProbePayload, Exception] | None = None
|
42
42
|
for result in probes:
|
43
43
|
if isinstance(result.probe, NullByteInHeader) and result.is_failure:
|
44
|
-
from
|
45
|
-
from
|
44
|
+
from schemathesis.specs.openapi import formats
|
45
|
+
from schemathesis.specs.openapi.formats import HEADER_FORMAT, header_values
|
46
46
|
|
47
47
|
formats.register(HEADER_FORMAT, header_values(exclude_characters="\n\r\x00"))
|
48
|
-
|
49
|
-
status = Status.ERROR
|
50
|
-
payload = Err(result.error)
|
51
|
-
else:
|
52
|
-
status = Status.SUCCESS
|
53
|
-
payload = Ok(ProbePayload(probes=probes))
|
48
|
+
payload = Ok(ProbePayload(probes=probes))
|
54
49
|
yield events.PhaseFinished(phase=phase, status=status, payload=payload)
|
55
50
|
|
56
51
|
|
@@ -177,6 +177,18 @@ class CoverageContext:
|
|
177
177
|
return bool(value)
|
178
178
|
return True
|
179
179
|
|
180
|
+
def can_be_negated(self, schema: dict[str, Any]) -> bool:
|
181
|
+
# Path, query, header, and cookie parameters will be stringified anyway
|
182
|
+
# If there are no constraints, then anything will match the original schema after serialization
|
183
|
+
if self.location in ("query", "path", "header", "cookie"):
|
184
|
+
cleaned = {
|
185
|
+
k: v
|
186
|
+
for k, v in schema.items()
|
187
|
+
if not k.startswith("x-") and k not in ["description", "example", "examples"]
|
188
|
+
}
|
189
|
+
return cleaned != {}
|
190
|
+
return True
|
191
|
+
|
180
192
|
def generate_from(self, strategy: st.SearchStrategy) -> Any:
|
181
193
|
return cached_draw(strategy)
|
182
194
|
|
@@ -389,6 +401,8 @@ def cover_schema_iter(
|
|
389
401
|
yield from _cover_positive_for_type(ctx, schema, ty)
|
390
402
|
if GenerationMode.NEGATIVE in ctx.generation_modes:
|
391
403
|
template = None
|
404
|
+
if not ctx.can_be_negated(schema):
|
405
|
+
return
|
392
406
|
for key, value in schema.items():
|
393
407
|
with _ignore_unfixable(), ctx.at(key):
|
394
408
|
if key == "enum":
|
@@ -624,7 +624,9 @@ def _iter_coverage_cases(
|
|
624
624
|
),
|
625
625
|
)
|
626
626
|
# Generate duplicate query parameters
|
627
|
-
if
|
627
|
+
# NOTE: if the query schema has no constraints, then we may have no negative test cases at all
|
628
|
+
# as they all will match the original schema and therefore will be considered as positive ones
|
629
|
+
if generate_duplicate_query_parameters and operation.query and "query" in template:
|
628
630
|
container = template["query"]
|
629
631
|
for parameter in operation.query:
|
630
632
|
instant = Instant()
|
@@ -656,24 +658,26 @@ def _iter_coverage_cases(
|
|
656
658
|
name = parameter.name
|
657
659
|
location = parameter.location
|
658
660
|
container_name = LOCATION_TO_CONTAINER[location]
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
661
|
+
# NOTE: if the schema is overly permissive we may not have any negative test cases
|
662
|
+
if container_name in template:
|
663
|
+
container = template[container_name]
|
664
|
+
data = template.with_container(
|
665
|
+
container_name=container_name,
|
666
|
+
value={k: v for k, v in container.items() if k != name},
|
667
|
+
generation_mode=GenerationMode.NEGATIVE,
|
668
|
+
)
|
669
|
+
yield operation.Case(
|
670
|
+
**data.kwargs,
|
671
|
+
_meta=CaseMetadata(
|
672
|
+
generation=GenerationInfo(time=instant.elapsed, mode=GenerationMode.NEGATIVE),
|
673
|
+
components=data.components,
|
674
|
+
phase=PhaseInfo.coverage(
|
675
|
+
description=f"Missing `{name}` at {location}",
|
676
|
+
parameter=name,
|
677
|
+
parameter_location=location,
|
678
|
+
),
|
674
679
|
),
|
675
|
-
)
|
676
|
-
)
|
680
|
+
)
|
677
681
|
# Generate combinations for each location
|
678
682
|
for location, parameter_set in [
|
679
683
|
("query", operation.query),
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: schemathesis
|
3
|
-
Version: 4.0.
|
3
|
+
Version: 4.0.9
|
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
|
@@ -23,7 +23,7 @@ schemathesis/cli/commands/run/handlers/__init__.py,sha256=TPZ3KdGi8m0fjlN0GjA31M
|
|
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
25
|
schemathesis/cli/commands/run/handlers/junitxml.py,sha256=ydk6Ofj-Uti6H8EucT4Snp85cmTA5W7uVpKkoHrIDKE,2586
|
26
|
-
schemathesis/cli/commands/run/handlers/output.py,sha256=
|
26
|
+
schemathesis/cli/commands/run/handlers/output.py,sha256=zlI0M5PuzduzluzONv3eyuoWWnigPkErPpUtjgHWESE,62476
|
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
|
@@ -72,11 +72,11 @@ schemathesis/engine/__init__.py,sha256=QaFE-FinaTAaarteADo2RRMJ-Sz6hZB9TzD5KjMin
|
|
72
72
|
schemathesis/engine/context.py,sha256=x-I9KX6rO6hdCvvN8FEdzIZBqIcNaxdNYHgQjcXbZhM,3931
|
73
73
|
schemathesis/engine/control.py,sha256=FXzP8dxL47j1Giqpy2-Bsr_MdMw9YiATSK_UfpFwDtk,1348
|
74
74
|
schemathesis/engine/core.py,sha256=5jfAqFH0XSD7NVgoSXuUPW-dooItscneAzUNq1RBh1E,5712
|
75
|
-
schemathesis/engine/errors.py,sha256=
|
75
|
+
schemathesis/engine/errors.py,sha256=JAWBsgmtXBeWkSL84rBvqDIQ4FFjiOn6qq8yL6Xcuhw,19130
|
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=fhe_1ZPYDCfyzqjeg_0aWK_dhXlsgacE3_VVlbhkwdI,5528
|
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
|
@@ -85,13 +85,13 @@ schemathesis/engine/phases/unit/_executor.py,sha256=9MmZoKSBVSPk0LWwN3PZ3iaO9nzp
|
|
85
85
|
schemathesis/engine/phases/unit/_pool.py,sha256=iU0hdHDmohPnEv7_S1emcabuzbTf-Cznqwn0pGQ5wNQ,2480
|
86
86
|
schemathesis/generation/__init__.py,sha256=tvNO2FLiY8z3fZ_kL_QJhSgzXfnT4UqwSXMHCwfLI0g,645
|
87
87
|
schemathesis/generation/case.py,sha256=MuqnKsJBpGm2gaqDFdJi1yGSWgBhqJUwtYaX97kfXgo,11820
|
88
|
-
schemathesis/generation/coverage.py,sha256=
|
88
|
+
schemathesis/generation/coverage.py,sha256=A5bDFxXVSpEYhbKPlSpk3AY0t3TLeoKcwiIXZuO9DOY,49878
|
89
89
|
schemathesis/generation/meta.py,sha256=adkoMuCfzSjHJ9ZDocQn0GnVldSCkLL3eVR5A_jafwM,2552
|
90
90
|
schemathesis/generation/metrics.py,sha256=cZU5HdeAMcLFEDnTbNE56NuNq4P0N4ew-g1NEz5-kt4,2836
|
91
91
|
schemathesis/generation/modes.py,sha256=Q1fhjWr3zxabU5qdtLvKfpMFZJAwlW9pnxgenjeXTyU,481
|
92
92
|
schemathesis/generation/overrides.py,sha256=OBWqDQPreiliaf2M-oyXppVKHoJkCRzxtwSJx1b6AFw,3759
|
93
93
|
schemathesis/generation/hypothesis/__init__.py,sha256=SVwM-rx07jPZzms0idWYACgUtWAxh49HRuTnaQ__zf0,1549
|
94
|
-
schemathesis/generation/hypothesis/builder.py,sha256=
|
94
|
+
schemathesis/generation/hypothesis/builder.py,sha256=EPJkeyeirU-pMuD4NGrY1e4HRp0cmBNg_1NLRFRxOfk,34550
|
95
95
|
schemathesis/generation/hypothesis/examples.py,sha256=6eGaKUEC3elmKsaqfKj1sLvM8EHc-PWT4NRBq4NI0Rs,1409
|
96
96
|
schemathesis/generation/hypothesis/given.py,sha256=sTZR1of6XaHAPWtHx2_WLlZ50M8D5Rjux0GmWkWjDq4,2337
|
97
97
|
schemathesis/generation/hypothesis/reporting.py,sha256=uDVow6Ya8YFkqQuOqRsjbzsbyP4KKfr3jA7ZaY4FuKY,279
|
@@ -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.9.dist-info/METADATA,sha256=X7vMnzd00mlF78IKDhy-Bl6Yz9abZkE2Dxr424OemLo,8471
|
161
|
+
schemathesis-4.0.9.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
162
|
+
schemathesis-4.0.9.dist-info/entry_points.txt,sha256=hiK3un-xfgPdwj9uj16YVDtTNpO128bmk0U82SMv8ZQ,152
|
163
|
+
schemathesis-4.0.9.dist-info/licenses/LICENSE,sha256=2Ve4J8v5jMQAWrT7r1nf3bI8Vflk3rZVQefiF2zpxwg,1121
|
164
|
+
schemathesis-4.0.9.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|