schemathesis 4.0.2__py3-none-any.whl → 4.0.3__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.
@@ -244,19 +244,25 @@ class Case:
244
244
 
245
245
  response = Response.from_any(response)
246
246
 
247
+ config = self.operation.schema.config.checks_config_for(
248
+ operation=self.operation, phase=self.meta.phase.name.value if self.meta is not None else None
249
+ )
250
+ if not checks:
251
+ # Checks are not specified explicitly, derive from the config
252
+ checks = []
253
+ for check in CHECKS.get_all():
254
+ name = check.__name__
255
+ if config.get_by_name(name=name).enabled:
256
+ checks.append(check)
247
257
  checks = [
248
- check
249
- for check in list(checks or CHECKS.get_all()) + list(additional_checks or [])
250
- if check not in set(excluded_checks or [])
258
+ check for check in list(checks) + list(additional_checks or []) if check not in set(excluded_checks or [])
251
259
  ]
252
260
 
253
261
  ctx = CheckContext(
254
262
  override=self._override,
255
263
  auth=None,
256
264
  headers=CaseInsensitiveDict(headers) if headers else None,
257
- config=self.operation.schema.config.checks_config_for(
258
- operation=self.operation, phase=self.meta.phase.name.value if self.meta is not None else None
259
- ),
265
+ config=config,
260
266
  transport_kwargs=transport_kwargs,
261
267
  recorder=None,
262
268
  )
@@ -20,6 +20,7 @@ from schemathesis.core.errors import (
20
20
  InvalidHeadersExample,
21
21
  InvalidRegexPattern,
22
22
  InvalidSchema,
23
+ SchemathesisError,
23
24
  SerializationNotPossible,
24
25
  format_exception,
25
26
  )
@@ -263,20 +264,27 @@ def pytest_pycollect_makeitem(collector: nodes.Collector, name: str, obj: Any) -
263
264
 
264
265
  @pytest.hookimpl(tryfirst=True) # type: ignore[misc]
265
266
  def pytest_exception_interact(node: Function, call: pytest.CallInfo, report: pytest.TestReport) -> None:
266
- if call.excinfo and call.excinfo.type is FailureGroup:
267
- tb_entries = list(call.excinfo.traceback)
268
- total_frames = len(tb_entries)
269
-
270
- # Keep internal Schemathesis frames + one extra one from the caller
271
- skip_frames = 0
272
- for i in range(total_frames - 1, -1, -1):
273
- entry = tb_entries[i]
274
-
275
- if not str(entry.path).endswith("schemathesis/generation/case.py"):
276
- skip_frames = i
277
- break
278
-
279
- report.longrepr = "".join(format_exception(call.excinfo.value, with_traceback=True, skip_frames=skip_frames))
267
+ if call.excinfo:
268
+ if issubclass(call.excinfo.type, SchemathesisError) and hasattr(call.excinfo.value, "__notes__"):
269
+ # Hypothesis adds quite a lot of additional debug information which is not that helpful in Schemathesis
270
+ call.excinfo.value.__notes__.clear()
271
+ report.longrepr = "".join(format_exception(call.excinfo.value))
272
+ if call.excinfo.type is FailureGroup:
273
+ tb_entries = list(call.excinfo.traceback)
274
+ total_frames = len(tb_entries)
275
+
276
+ # Keep internal Schemathesis frames + one extra one from the caller
277
+ skip_frames = 0
278
+ for i in range(total_frames - 1, -1, -1):
279
+ entry = tb_entries[i]
280
+
281
+ if not str(entry.path).endswith("schemathesis/generation/case.py"):
282
+ skip_frames = i
283
+ break
284
+
285
+ report.longrepr = "".join(
286
+ format_exception(call.excinfo.value, with_traceback=True, skip_frames=skip_frames)
287
+ )
280
288
 
281
289
 
282
290
  @hookimpl(wrapper=True)
@@ -120,7 +120,7 @@ def openapi_cases(
120
120
  for media_type in all_media_types
121
121
  ):
122
122
  # None of media types defined for this operation are not supported
123
- raise SerializationNotPossible.from_media_types(*all_media_types)
123
+ raise SerializationNotPossible.from_media_types(*all_media_types) from None
124
124
  # Other media types are possible - avoid choosing this media type in the future
125
125
  event_text = f"Can't serialize data to `{parameter.media_type}`."
126
126
  note(f"{event_text} {SERIALIZERS_SUGGESTION_MESSAGE}")
@@ -85,6 +85,12 @@ class RequestsTransport(BaseTransport["requests.Session"]):
85
85
  def send(self, case: Case, *, session: requests.Session | None = None, **kwargs: Any) -> Response:
86
86
  import requests
87
87
 
88
+ config = case.operation.schema.config
89
+
90
+ timeout = config.request_timeout_for(operation=case.operation)
91
+ verify = config.tls_verify_for(operation=case.operation)
92
+ cert = config.request_cert_for(operation=case.operation)
93
+
88
94
  if session is not None and session.headers:
89
95
  # These headers are explicitly provided via config or CLI args.
90
96
  # They have lower priority than ones provided via `kwargs`
@@ -94,6 +100,14 @@ class RequestsTransport(BaseTransport["requests.Session"]):
94
100
  kwargs["headers"] = headers
95
101
 
96
102
  data = self.serialize_case(case, **kwargs)
103
+
104
+ if verify is not None:
105
+ data.setdefault("verify", verify)
106
+ if timeout is not None:
107
+ data.setdefault("timeout", timeout)
108
+ if cert is not None:
109
+ data.setdefault("cert", cert)
110
+
97
111
  kwargs.pop("base_url", None)
98
112
  data.update({key: value for key, value in kwargs.items() if key not in data})
99
113
  data.setdefault("timeout", DEFAULT_RESPONSE_TIMEOUT)
@@ -119,7 +133,6 @@ class RequestsTransport(BaseTransport["requests.Session"]):
119
133
  verify = data.get("verify", True)
120
134
 
121
135
  try:
122
- config = case.operation.schema.config
123
136
  rate_limit = config.rate_limit_for(operation=case.operation)
124
137
  with ratelimit(rate_limit, config.base_url):
125
138
  response = session.request(**data) # type: ignore
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: schemathesis
3
- Version: 4.0.2
3
+ Version: 4.0.3
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
@@ -84,7 +84,7 @@ schemathesis/engine/phases/unit/__init__.py,sha256=BvZh39LZmXg90Cy_Tn0cQY5y7eWzY
84
84
  schemathesis/engine/phases/unit/_executor.py,sha256=jay_D7fmmBTjZigifmY30RiVP5Jb0OlK450fknSWZ_I,16471
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
- schemathesis/generation/case.py,sha256=WbOJagE7Gjz3ZvBxzRl8vJHgm_LjW0wf2oRuPzoj6LI,11547
87
+ schemathesis/generation/case.py,sha256=MuqnKsJBpGm2gaqDFdJi1yGSWgBhqJUwtYaX97kfXgo,11820
88
88
  schemathesis/generation/coverage.py,sha256=bKP0idU5-eiK4VwhH4kjxDPtCZzMg81mbN1tEDuT6EA,47913
89
89
  schemathesis/generation/meta.py,sha256=adkoMuCfzSjHJ9ZDocQn0GnVldSCkLL3eVR5A_jafwM,2552
90
90
  schemathesis/generation/metrics.py,sha256=cZU5HdeAMcLFEDnTbNE56NuNq4P0N4ew-g1NEz5-kt4,2836
@@ -110,7 +110,7 @@ schemathesis/pytest/__init__.py,sha256=7W0q-Thcw03IAQfXE_Mo8JPZpUdHJzfu85fjK1Zdf
110
110
  schemathesis/pytest/control_flow.py,sha256=F8rAPsPeNv_sJiJgbZYtTpwKWjauZmqFUaKroY2GmQI,217
111
111
  schemathesis/pytest/lazy.py,sha256=u58q0orI0zisivLJKJkSo53RaQMPLSMiE0vJ1TQ9_uA,11073
112
112
  schemathesis/pytest/loaders.py,sha256=Sbv8e5F77_x4amLP50iwubfm6kpOhx7LhLFGsVXW5Ys,925
113
- schemathesis/pytest/plugin.py,sha256=m4zGLw6A537o4mBb9FvuM4jmAoxfpg0DPLWq5eCLXGc,13818
113
+ schemathesis/pytest/plugin.py,sha256=MXllorF5SqUgqjLyhHb-P0wlWokvZMg0Rm6OTRoFoas,14266
114
114
  schemathesis/python/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
115
115
  schemathesis/python/asgi.py,sha256=5PyvuTBaivvyPUEi3pwJni91K1kX5Zc0u9c6c1D8a1Q,287
116
116
  schemathesis/python/wsgi.py,sha256=uShAgo_NChbfYaV1117e6UHp0MTg7jaR0Sy_to3Jmf8,219
@@ -123,7 +123,7 @@ schemathesis/specs/graphql/schemas.py,sha256=ezkqgMwx37tMWlhy_I0ahDF1Q44emDSJkyj
123
123
  schemathesis/specs/graphql/validation.py,sha256=-W1Noc1MQmTb4RX-gNXMeU2qkgso4mzVfHxtdLkCPKM,1422
124
124
  schemathesis/specs/openapi/__init__.py,sha256=C5HOsfuDJGq_3mv8CRBvRvb0Diy1p0BFdqyEXMS-loE,238
125
125
  schemathesis/specs/openapi/_cache.py,sha256=HpglmETmZU0RCHxp3DO_sg5_B_nzi54Zuw9vGzzYCxY,4295
126
- schemathesis/specs/openapi/_hypothesis.py,sha256=005E_gH4YGhOORQyJtP6vkOOM0-FgiES06JpXRcdL5c,22601
126
+ schemathesis/specs/openapi/_hypothesis.py,sha256=NuXucpwn8jjL_O0anja1TPqEuXyuFq8quIuECIW9BLY,22611
127
127
  schemathesis/specs/openapi/checks.py,sha256=mKJ-ZkbjhbXS4eWDZiv8zslXKFDqkE3Mp4N8TVDHiI0,29801
128
128
  schemathesis/specs/openapi/constants.py,sha256=JqM_FHOenqS_MuUE9sxVQ8Hnw0DNM8cnKDwCwPLhID4,783
129
129
  schemathesis/specs/openapi/converter.py,sha256=lil8IewM5j8tvt4lpA9g_KITvIwx1M96i45DNSHNjoc,3505
@@ -154,11 +154,11 @@ schemathesis/specs/openapi/stateful/links.py,sha256=h5q40jUbcIk5DS_Tih1cvFJxS_Qx
154
154
  schemathesis/transport/__init__.py,sha256=6yg_RfV_9L0cpA6qpbH-SL9_3ggtHQji9CZrpIkbA6s,5321
155
155
  schemathesis/transport/asgi.py,sha256=qTClt6oT_xUEWnRHokACN_uqCNNUZrRPT6YG0PjbElY,926
156
156
  schemathesis/transport/prepare.py,sha256=iiB8KTAqnnuqjWzblIPiGVdkGIF7Yr1SAEz-KZzBNXw,4581
157
- schemathesis/transport/requests.py,sha256=7N0KYcCEVba7fpeL8OphoY0W8B-qNOARrgYC51cg3AE,10227
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.2.dist-info/METADATA,sha256=wqlw5M4fnuJgE7zRWt8qKu6TiP1wsPJtMiRLCMfluu8,8471
161
- schemathesis-4.0.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
162
- schemathesis-4.0.2.dist-info/entry_points.txt,sha256=hiK3un-xfgPdwj9uj16YVDtTNpO128bmk0U82SMv8ZQ,152
163
- schemathesis-4.0.2.dist-info/licenses/LICENSE,sha256=2Ve4J8v5jMQAWrT7r1nf3bI8Vflk3rZVQefiF2zpxwg,1121
164
- schemathesis-4.0.2.dist-info/RECORD,,
160
+ schemathesis-4.0.3.dist-info/METADATA,sha256=hm5ioN50c0UyShRq7AN-9qzDnKGLMYSxQwXw1Lw7jTc,8471
161
+ schemathesis-4.0.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
162
+ schemathesis-4.0.3.dist-info/entry_points.txt,sha256=hiK3un-xfgPdwj9uj16YVDtTNpO128bmk0U82SMv8ZQ,152
163
+ schemathesis-4.0.3.dist-info/licenses/LICENSE,sha256=2Ve4J8v5jMQAWrT7r1nf3bI8Vflk3rZVQefiF2zpxwg,1121
164
+ schemathesis-4.0.3.dist-info/RECORD,,