schemathesis 3.30.3__py3-none-any.whl → 3.30.4__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.
@@ -98,7 +98,9 @@ def create_test(
98
98
  existing_settings = remove_explain_phase(existing_settings)
99
99
  wrapped_test._hypothesis_internal_use_settings = existing_settings # type: ignore
100
100
  if Phase.explicit in existing_settings.phases:
101
- wrapped_test = add_examples(wrapped_test, operation, hook_dispatcher=hook_dispatcher)
101
+ wrapped_test = add_examples(
102
+ wrapped_test, operation, hook_dispatcher=hook_dispatcher, as_strategy_kwargs=as_strategy_kwargs
103
+ )
102
104
  return wrapped_test
103
105
 
104
106
 
@@ -138,12 +140,20 @@ def make_async_test(test: Callable) -> Callable:
138
140
  return async_run
139
141
 
140
142
 
141
- def add_examples(test: Callable, operation: APIOperation, hook_dispatcher: HookDispatcher | None = None) -> Callable:
143
+ def add_examples(
144
+ test: Callable,
145
+ operation: APIOperation,
146
+ hook_dispatcher: HookDispatcher | None = None,
147
+ as_strategy_kwargs: dict[str, Any] | None = None,
148
+ ) -> Callable:
142
149
  """Add examples to the Hypothesis test, if they are specified in the schema."""
143
150
  from hypothesis_jsonschema._canonicalise import HypothesisRefResolutionError
144
151
 
145
152
  try:
146
- examples: list[Case] = [get_single_example(strategy) for strategy in operation.get_strategies_from_examples()]
153
+ examples: list[Case] = [
154
+ get_single_example(strategy)
155
+ for strategy in operation.get_strategies_from_examples(as_strategy_kwargs=as_strategy_kwargs)
156
+ ]
147
157
  except (
148
158
  OperationSchemaError,
149
159
  HypothesisRefResolutionError,
schemathesis/models.py CHANGED
@@ -675,9 +675,11 @@ class APIOperation(Generic[P, C]):
675
675
  def get_security_requirements(self) -> list[str]:
676
676
  return self.schema.get_security_requirements(self)
677
677
 
678
- def get_strategies_from_examples(self) -> list[st.SearchStrategy[Case]]:
678
+ def get_strategies_from_examples(
679
+ self, as_strategy_kwargs: dict[str, Any] | None = None
680
+ ) -> list[st.SearchStrategy[Case]]:
679
681
  """Get examples from the API operation."""
680
- return self.schema.get_strategies_from_examples(self)
682
+ return self.schema.get_strategies_from_examples(self, as_strategy_kwargs=as_strategy_kwargs)
681
683
 
682
684
  def get_stateful_tests(self, response: GenericResponse, stateful: Stateful | None) -> Sequence[StatefulTest]:
683
685
  return self.schema.get_stateful_tests(response, self, stateful)
schemathesis/schemas.py CHANGED
@@ -173,7 +173,9 @@ class BaseSchema(Mapping):
173
173
  ) -> Generator[Result[APIOperation, OperationSchemaError], None, None]:
174
174
  raise NotImplementedError
175
175
 
176
- def get_strategies_from_examples(self, operation: APIOperation) -> list[SearchStrategy[Case]]:
176
+ def get_strategies_from_examples(
177
+ self, operation: APIOperation, as_strategy_kwargs: dict[str, Any] | None = None
178
+ ) -> list[SearchStrategy[Case]]:
177
179
  """Get examples from the API operation."""
178
180
  raise NotImplementedError
179
181
 
@@ -249,7 +249,9 @@ class GraphQLSchema(BaseSchema):
249
249
  **kwargs,
250
250
  )
251
251
 
252
- def get_strategies_from_examples(self, operation: APIOperation) -> list[SearchStrategy[Case]]:
252
+ def get_strategies_from_examples(
253
+ self, operation: APIOperation, as_strategy_kwargs: dict[str, Any] | None = None
254
+ ) -> list[SearchStrategy[Case]]:
253
255
  return []
254
256
 
255
257
  def get_stateful_tests(
@@ -42,7 +42,9 @@ class BodyExample:
42
42
  Example = Union[ParameterExample, BodyExample]
43
43
 
44
44
 
45
- def get_strategies_from_examples(operation: APIOperation[OpenAPIParameter, Case]) -> list[SearchStrategy[Case]]:
45
+ def get_strategies_from_examples(
46
+ operation: APIOperation[OpenAPIParameter, Case], as_strategy_kwargs: dict[str, Any] | None = None
47
+ ) -> list[SearchStrategy[Case]]:
46
48
  """Build a set of strategies that generate test cases based on explicit examples in the schema."""
47
49
  maps = {}
48
50
  for location, container in LOCATION_TO_CONTAINER.items():
@@ -65,7 +67,7 @@ def get_strategies_from_examples(operation: APIOperation[OpenAPIParameter, Case]
65
67
  # Add examples from parameter's schemas
66
68
  examples.extend(extract_from_schemas(operation))
67
69
  return [
68
- get_case_strategy(operation=operation, **parameters).map(serialize_components)
70
+ get_case_strategy(operation=operation, **{**parameters, **(as_strategy_kwargs or {})}).map(serialize_components)
69
71
  for parameters in produce_combinations(examples)
70
72
  ]
71
73
 
@@ -399,7 +399,9 @@ class BaseOpenAPISchema(BaseSchema):
399
399
  """Content types available for this API operation."""
400
400
  raise NotImplementedError
401
401
 
402
- def get_strategies_from_examples(self, operation: APIOperation) -> list[SearchStrategy[Case]]:
402
+ def get_strategies_from_examples(
403
+ self, operation: APIOperation, as_strategy_kwargs: dict[str, Any] | None = None
404
+ ) -> list[SearchStrategy[Case]]:
403
405
  """Get examples from the API operation."""
404
406
  raise NotImplementedError
405
407
 
@@ -924,9 +926,11 @@ class SwaggerV20(BaseOpenAPISchema):
924
926
  )
925
927
  return collected
926
928
 
927
- def get_strategies_from_examples(self, operation: APIOperation) -> list[SearchStrategy[Case]]:
929
+ def get_strategies_from_examples(
930
+ self, operation: APIOperation, as_strategy_kwargs: dict[str, Any] | None = None
931
+ ) -> list[SearchStrategy[Case]]:
928
932
  """Get examples from the API operation."""
929
- return get_strategies_from_examples(operation)
933
+ return get_strategies_from_examples(operation, as_strategy_kwargs=as_strategy_kwargs)
930
934
 
931
935
  def get_response_schema(self, definition: dict[str, Any], scope: str) -> tuple[list[str], dict[str, Any] | None]:
932
936
  scopes, definition = self.resolver.resolve_in_scope(definition, scope)
@@ -1088,9 +1092,11 @@ class OpenApi30(SwaggerV20):
1088
1092
  return scopes, to_json_schema_recursive(option["schema"], self.nullable_name, is_response_schema=True)
1089
1093
  return scopes, None
1090
1094
 
1091
- def get_strategies_from_examples(self, operation: APIOperation) -> list[SearchStrategy[Case]]:
1095
+ def get_strategies_from_examples(
1096
+ self, operation: APIOperation, as_strategy_kwargs: dict[str, Any] | None = None
1097
+ ) -> list[SearchStrategy[Case]]:
1092
1098
  """Get examples from the API operation."""
1093
- return get_strategies_from_examples(operation)
1099
+ return get_strategies_from_examples(operation, as_strategy_kwargs=as_strategy_kwargs)
1094
1100
 
1095
1101
  def get_content_types(self, operation: APIOperation, response: GenericResponse) -> list[str]:
1096
1102
  definitions = self._get_response_definitions(operation, response)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: schemathesis
3
- Version: 3.30.3
3
+ Version: 3.30.4
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://schemathesis.readthedocs.io/en/stable/changelog.html
@@ -1,7 +1,7 @@
1
1
  schemathesis/__init__.py,sha256=pNaTfaC3NSdediNQuH9QAcuIx3U-MmSydvhS65FZrxw,1984
2
2
  schemathesis/_compat.py,sha256=y4RZd59i2NCnZ91VQhnKeMn_8t3SgvLOk2Xm8nymUHY,1837
3
3
  schemathesis/_dependency_versions.py,sha256=pjEkkGAfOQJYNb-9UOo84V8nj_lKHr_TGDVdFwY2UU0,816
4
- schemathesis/_hypothesis.py,sha256=GeH2umc3HiK93JZ9tOKALp2nb3mbpaLFkq4SbCY0_TM,10998
4
+ schemathesis/_hypothesis.py,sha256=Igb1x3am3tafVhZ6ikY7yrmQdNthC0PZFEYVCdNAA3w,11207
5
5
  schemathesis/_lazy_import.py,sha256=aMhWYgbU2JOltyWBb32vnWBb6kykOghucEzI_F70yVE,470
6
6
  schemathesis/_override.py,sha256=3CbA7P9Q89W3ymaYxiOV5Xpv1yhoBqroLK4YRpYMjX4,1630
7
7
  schemathesis/_rate_limiter.py,sha256=q_XWst5hzuAyXQRiZc4s_bx7-JlPYZM_yKDmeavt3oo,242
@@ -17,11 +17,11 @@ schemathesis/graphql.py,sha256=YkoKWY5K8lxp7H3ikAs-IsoDbiPwJvChG7O8p3DgwtI,229
17
17
  schemathesis/hooks.py,sha256=dveqMmThIvt4fDahUXhU2nCq5pFvYjzzd1Ys_MhrJZA,12398
18
18
  schemathesis/lazy.py,sha256=eVdGkTZK0fWvUlFUCFGGlViH2NWEtYIjxiNkF4fBWhI,15218
19
19
  schemathesis/loaders.py,sha256=OtCD1o0TVmSNAUF7dgHpouoAXtY6w9vEtsRVGv4lE0g,4588
20
- schemathesis/models.py,sha256=byTGJD6zyXFvSvQCe-Mxu3lOdvU3EQ9vmadv6Jv6f5I,44025
20
+ schemathesis/models.py,sha256=4lICPGwcVHCICex774KFOFloqPdJWN6uI4Mq47bfSuw,44128
21
21
  schemathesis/parameters.py,sha256=PndmqQRlEYsCt1kWjSShPsFf6vj7X_7FRdz_-A95eNg,2258
22
22
  schemathesis/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
23
  schemathesis/sanitization.py,sha256=mRR4YvXpzqbmgX8Xu6rume6LBcz9g_oyusvbesZl44I,8958
24
- schemathesis/schemas.py,sha256=aa84Kmin4lu68vU4y3DpPGo4Z1Pt7LFCqe9kzW35Asc,18267
24
+ schemathesis/schemas.py,sha256=nUJIfR0mXYpKwEX3mZiS3hpUDdkD3vulROVeovL0dqU,18331
25
25
  schemathesis/serializers.py,sha256=kxXZ-UGa1v_vOm0sC4QYcrNv4rfvI7tHGT2elRVbCbc,11649
26
26
  schemathesis/targets.py,sha256=N1Zzgqa1PNycWIeGpra7q-6ASn2x4r9Jompn35bmlsE,1163
27
27
  schemathesis/throttling.py,sha256=aisUc4MJDGIOGUAs9L2DlWWpdd4KyAFuNVKhYoaUC9M,1719
@@ -94,7 +94,7 @@ schemathesis/specs/graphql/_cache.py,sha256=7ras3q_InDJBPykgHroerl9f2jFamC8xJD35
94
94
  schemathesis/specs/graphql/loaders.py,sha256=qxNGL67_AfhoRh0hIxlnJVe6do26vqwWS_TrJtB-Lro,12198
95
95
  schemathesis/specs/graphql/nodes.py,sha256=bE3G1kNmqJ8OV4igBvIK-UORrkQA6Nofduf87O3TD9I,541
96
96
  schemathesis/specs/graphql/scalars.py,sha256=9tvLTiYVe8A_E8ASA0czz3Z0Mp9lyak7R4wHpAE_jKo,1805
97
- schemathesis/specs/graphql/schemas.py,sha256=ICIejnv05Q9uxljQU06i9RSVa10mAdTESBfM17wMkaI,13491
97
+ schemathesis/specs/graphql/schemas.py,sha256=i6fAW9pYcOplQE7BejP6P8GQ9z6Y43Vx4_feVvbd1B4,13555
98
98
  schemathesis/specs/graphql/validation.py,sha256=uINIOt-2E7ZuQV2CxKzwez-7L9tDtqzMSpnVoRWvxy0,1635
99
99
  schemathesis/specs/openapi/__init__.py,sha256=HDcx3bqpa6qWPpyMrxAbM3uTo0Lqpg-BUNZhDJSJKnw,279
100
100
  schemathesis/specs/openapi/_cache.py,sha256=PAiAu4X_a2PQgD2lG5H3iisXdyg4SaHpU46bRZvfNkM,4320
@@ -103,7 +103,7 @@ schemathesis/specs/openapi/checks.py,sha256=1Fu3Kgai9ySCoGtCrx99Q9oVCEWXgkqHd1gT
103
103
  schemathesis/specs/openapi/constants.py,sha256=JqM_FHOenqS_MuUE9sxVQ8Hnw0DNM8cnKDwCwPLhID4,783
104
104
  schemathesis/specs/openapi/converter.py,sha256=TaYgc5BBHPdkN-n0lqpbeVgLu3eL3L8Wu3y_Vo3TJaQ,2800
105
105
  schemathesis/specs/openapi/definitions.py,sha256=Z186F0gNBSCmPg-Kk7Q-n6XxEZHIOzgUyeqixlC62XE,94058
106
- schemathesis/specs/openapi/examples.py,sha256=OxzcYWlNQzAjkNf8IAGxEGnQ4DelY4mtPwDLodWSRAE,15038
106
+ schemathesis/specs/openapi/examples.py,sha256=5bjmW3BnJVTiLlWZbimdfOzQQFR6m1P9G0FErr9g3WI,15128
107
107
  schemathesis/specs/openapi/filters.py,sha256=6Q9eNQ6zCR-NQkUxgnkSDWxfk3hsZuxemBv7v1rhwb4,1437
108
108
  schemathesis/specs/openapi/formats.py,sha256=JmmkQWNAj5XreXb7Edgj4LADAf4m86YulR_Ec8evpJ4,1220
109
109
  schemathesis/specs/openapi/links.py,sha256=2ucOLs50OhCqu0PEdbT_BGUM3fKnHBl97YGISLpAxLY,16023
@@ -111,7 +111,7 @@ schemathesis/specs/openapi/loaders.py,sha256=JJdIz1aT03J9WmUWTLOz6Yhuu69IqmhobQ9
111
111
  schemathesis/specs/openapi/media_types.py,sha256=dNTxpRQbY3SubdVjh4Cjb38R6Bc9MF9BsRQwPD87x0g,1017
112
112
  schemathesis/specs/openapi/parameters.py,sha256=_6vNCnPXcdxjfAQbykCRLHjvmTpu_02xDJghxDrGYr8,13611
113
113
  schemathesis/specs/openapi/references.py,sha256=i1Jd8EtEpSpauFW29DQsYM-JvB4jtYI7dpJAJcdjYe0,9276
114
- schemathesis/specs/openapi/schemas.py,sha256=rEsvuRM4mFbUEfaNfANadyfWhA-iaXbaBMZpjq1anBk,51761
114
+ schemathesis/specs/openapi/schemas.py,sha256=8nzbHG27VoubYXrIdmY9rBUKovS1RpVY6FTgSWE1aWQ,52031
115
115
  schemathesis/specs/openapi/security.py,sha256=sTOCYEsJmxGY2dglrlZRYmJzNZjEZAHm5bZtbYFHLmI,6612
116
116
  schemathesis/specs/openapi/serialization.py,sha256=5qGdFHZ3n80UlbSXrO_bkr4Al_7ci_Z3aSUjZczNDQY,11384
117
117
  schemathesis/specs/openapi/utils.py,sha256=-TCu0hTrlwp2x5qHNp-TxiHRMeIZC9OBmlhLssjRIiQ,742
@@ -144,8 +144,8 @@ schemathesis/transports/auth.py,sha256=4z7c-K7lfyyVqgR6X1v4yiE8ewR_ViAznWFTAsCL0
144
144
  schemathesis/transports/content_types.py,sha256=VrcRQvF5T_TUjrCyrZcYF2LOwKfs3IrLcMtkVSp1ImI,2189
145
145
  schemathesis/transports/headers.py,sha256=hr_AIDOfUxsJxpHfemIZ_uNG3_vzS_ZeMEKmZjbYiBE,990
146
146
  schemathesis/transports/responses.py,sha256=6-gvVcRK0Ho_lSydUysBNFWoJwZEiEgf6Iv-GWkQGd8,1675
147
- schemathesis-3.30.3.dist-info/METADATA,sha256=EJGm-5rC8P8sk_GgBDOfehfb5MdK4a9O6pU7jISsbTU,17671
148
- schemathesis-3.30.3.dist-info/WHEEL,sha256=hKi7AIIx6qfnsRbr087vpeJnrVUuDokDHZacPPMW7-Y,87
149
- schemathesis-3.30.3.dist-info/entry_points.txt,sha256=VHyLcOG7co0nOeuk8WjgpRETk5P1E2iCLrn26Zkn5uk,158
150
- schemathesis-3.30.3.dist-info/licenses/LICENSE,sha256=PsPYgrDhZ7g9uwihJXNG-XVb55wj2uYhkl2DD8oAzY0,1103
151
- schemathesis-3.30.3.dist-info/RECORD,,
147
+ schemathesis-3.30.4.dist-info/METADATA,sha256=AD5b4TDRZ1kayE-ZWdgV3RN3jLO7c-KHXdJPo_Ux2RM,17671
148
+ schemathesis-3.30.4.dist-info/WHEEL,sha256=hKi7AIIx6qfnsRbr087vpeJnrVUuDokDHZacPPMW7-Y,87
149
+ schemathesis-3.30.4.dist-info/entry_points.txt,sha256=VHyLcOG7co0nOeuk8WjgpRETk5P1E2iCLrn26Zkn5uk,158
150
+ schemathesis-3.30.4.dist-info/licenses/LICENSE,sha256=PsPYgrDhZ7g9uwihJXNG-XVb55wj2uYhkl2DD8oAzY0,1103
151
+ schemathesis-3.30.4.dist-info/RECORD,,