types-WebTest 3.0.0.20260612__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.
@@ -0,0 +1,41 @@
1
+ Metadata-Version: 2.4
2
+ Name: types-WebTest
3
+ Version: 3.0.0.20260612
4
+ Summary: Typing stubs for WebTest
5
+ License-Expression: Apache-2.0
6
+ Project-URL: Homepage, https://github.com/python/typeshed
7
+ Project-URL: GitHub, https://github.com/python/typeshed
8
+ Project-URL: Changes, https://github.com/typeshed-internal/stub_uploader/blob/main/data/changelogs/WebTest.md
9
+ Project-URL: Issue tracker, https://github.com/python/typeshed/issues
10
+ Project-URL: Chat, https://gitter.im/python/typing
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Typing :: Stubs Only
13
+ Requires-Python: >=3.10
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: types-waitress
17
+ Requires-Dist: types-WebOb
18
+ Requires-Dist: beautifulsoup4
19
+ Dynamic: license-file
20
+
21
+ ## Typing stubs for WebTest
22
+
23
+ This is a [type stub package](https://typing.python.org/en/latest/tutorials/external_libraries.html)
24
+ for the [`WebTest`](https://github.com/Pylons/webtest) package. It can be used by type checkers
25
+ to check code that uses `WebTest`. This version of
26
+ `types-WebTest` aims to provide accurate annotations for
27
+ `WebTest==3.0.*`.
28
+
29
+ This package is part of the [typeshed project](https://github.com/python/typeshed).
30
+ All fixes for types and metadata should be contributed there.
31
+ See [the README](https://github.com/python/typeshed/blob/main/README.md)
32
+ for more details. The source for this package can be found in the
33
+ [`stubs/WebTest`](https://github.com/python/typeshed/tree/main/stubs/WebTest)
34
+ directory.
35
+
36
+ This package was tested with the following type checkers:
37
+ * [mypy](https://github.com/python/mypy/) 2.1.0
38
+ * [pyright](https://github.com/microsoft/pyright) 1.1.410
39
+
40
+ It was generated from typeshed commit
41
+ [`7e1dfd9d2db07c7c846b1cb7235cda67f30878d2`](https://github.com/python/typeshed/commit/7e1dfd9d2db07c7c846b1cb7235cda67f30878d2).
@@ -0,0 +1,13 @@
1
+ types_webtest-3.0.0.20260612.dist-info/licenses/LICENSE,sha256=KV-FOMlK5cMEMwHPfP8chS2ranhqjd7kceBhtA1eyr4,12657
2
+ webtest-stubs/METADATA.toml,sha256=djZ2LE8VQbEY1-EH2dsmfuP9CfonkqMBMJhghUKmQ8g,143
3
+ webtest-stubs/__init__.pyi,sha256=K38SsaQvUe5yYAn0dBHG_6PWAYNbtsnDpbx1KTE5KoA,397
4
+ webtest-stubs/app.pyi,sha256=t-MebZdl4d4P9Wl8kcFOd_1_IRF23nIqdk3-t9vOPCE,7560
5
+ webtest-stubs/debugapp.pyi,sha256=_J00HKt4GoSzV9meZTO6qZLHbCz1-f-WThoFquhQ-1k,769
6
+ webtest-stubs/forms.pyi,sha256=Iz9KQMG2rcgi_uUWZUBULHTpb8LhvSYGb-Qd9ZZk0oY,6887
7
+ webtest-stubs/http.pyi,sha256=EEJ0CgXRIfi3cedcJYcx2J55R5MlsEcD8DPmrSURU6Q,1288
8
+ webtest-stubs/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
+ webtest-stubs/response.pyi,sha256=xWejO5yvd4qPuEqxCZsznJeafNu4HSbRah6Kxxas-xo,3276
10
+ types_webtest-3.0.0.20260612.dist-info/METADATA,sha256=5GhH3SMQnDp8tznkdTSS6WwN1gQCD33Qc4nEnGzJvRM,1814
11
+ types_webtest-3.0.0.20260612.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
12
+ types_webtest-3.0.0.20260612.dist-info/top_level.txt,sha256=Q8NAC4miPkn0sFqhHmWVaM7UBwpXG2jeh9oJuZylVB4,14
13
+ types_webtest-3.0.0.20260612.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,237 @@
1
+ The "typeshed" project is licensed under the terms of the Apache license, as
2
+ reproduced below.
3
+
4
+ = = = = =
5
+
6
+ Apache License
7
+ Version 2.0, January 2004
8
+ http://www.apache.org/licenses/
9
+
10
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
11
+
12
+ 1. Definitions.
13
+
14
+ "License" shall mean the terms and conditions for use, reproduction,
15
+ and distribution as defined by Sections 1 through 9 of this document.
16
+
17
+ "Licensor" shall mean the copyright owner or entity authorized by
18
+ the copyright owner that is granting the License.
19
+
20
+ "Legal Entity" shall mean the union of the acting entity and all
21
+ other entities that control, are controlled by, or are under common
22
+ control with that entity. For the purposes of this definition,
23
+ "control" means (i) the power, direct or indirect, to cause the
24
+ direction or management of such entity, whether by contract or
25
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
26
+ outstanding shares, or (iii) beneficial ownership of such entity.
27
+
28
+ "You" (or "Your") shall mean an individual or Legal Entity
29
+ exercising permissions granted by this License.
30
+
31
+ "Source" form shall mean the preferred form for making modifications,
32
+ including but not limited to software source code, documentation
33
+ source, and configuration files.
34
+
35
+ "Object" form shall mean any form resulting from mechanical
36
+ transformation or translation of a Source form, including but
37
+ not limited to compiled object code, generated documentation,
38
+ and conversions to other media types.
39
+
40
+ "Work" shall mean the work of authorship, whether in Source or
41
+ Object form, made available under the License, as indicated by a
42
+ copyright notice that is included in or attached to the work
43
+ (an example is provided in the Appendix below).
44
+
45
+ "Derivative Works" shall mean any work, whether in Source or Object
46
+ form, that is based on (or derived from) the Work and for which the
47
+ editorial revisions, annotations, elaborations, or other modifications
48
+ represent, as a whole, an original work of authorship. For the purposes
49
+ of this License, Derivative Works shall not include works that remain
50
+ separable from, or merely link (or bind by name) to the interfaces of,
51
+ the Work and Derivative Works thereof.
52
+
53
+ "Contribution" shall mean any work of authorship, including
54
+ the original version of the Work and any modifications or additions
55
+ to that Work or Derivative Works thereof, that is intentionally
56
+ submitted to Licensor for inclusion in the Work by the copyright owner
57
+ or by an individual or Legal Entity authorized to submit on behalf of
58
+ the copyright owner. For the purposes of this definition, "submitted"
59
+ means any form of electronic, verbal, or written communication sent
60
+ to the Licensor or its representatives, including but not limited to
61
+ communication on electronic mailing lists, source code control systems,
62
+ and issue tracking systems that are managed by, or on behalf of, the
63
+ Licensor for the purpose of discussing and improving the Work, but
64
+ excluding communication that is conspicuously marked or otherwise
65
+ designated in writing by the copyright owner as "Not a Contribution."
66
+
67
+ "Contributor" shall mean Licensor and any individual or Legal Entity
68
+ on behalf of whom a Contribution has been received by Licensor and
69
+ subsequently incorporated within the Work.
70
+
71
+ 2. Grant of Copyright License. Subject to the terms and conditions of
72
+ this License, each Contributor hereby grants to You a perpetual,
73
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
74
+ copyright license to reproduce, prepare Derivative Works of,
75
+ publicly display, publicly perform, sublicense, and distribute the
76
+ Work and such Derivative Works in Source or Object form.
77
+
78
+ 3. Grant of Patent License. Subject to the terms and conditions of
79
+ this License, each Contributor hereby grants to You a perpetual,
80
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
81
+ (except as stated in this section) patent license to make, have made,
82
+ use, offer to sell, sell, import, and otherwise transfer the Work,
83
+ where such license applies only to those patent claims licensable
84
+ by such Contributor that are necessarily infringed by their
85
+ Contribution(s) alone or by combination of their Contribution(s)
86
+ with the Work to which such Contribution(s) was submitted. If You
87
+ institute patent litigation against any entity (including a
88
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
89
+ or a Contribution incorporated within the Work constitutes direct
90
+ or contributory patent infringement, then any patent licenses
91
+ granted to You under this License for that Work shall terminate
92
+ as of the date such litigation is filed.
93
+
94
+ 4. Redistribution. You may reproduce and distribute copies of the
95
+ Work or Derivative Works thereof in any medium, with or without
96
+ modifications, and in Source or Object form, provided that You
97
+ meet the following conditions:
98
+
99
+ (a) You must give any other recipients of the Work or
100
+ Derivative Works a copy of this License; and
101
+
102
+ (b) You must cause any modified files to carry prominent notices
103
+ stating that You changed the files; and
104
+
105
+ (c) You must retain, in the Source form of any Derivative Works
106
+ that You distribute, all copyright, patent, trademark, and
107
+ attribution notices from the Source form of the Work,
108
+ excluding those notices that do not pertain to any part of
109
+ the Derivative Works; and
110
+
111
+ (d) If the Work includes a "NOTICE" text file as part of its
112
+ distribution, then any Derivative Works that You distribute must
113
+ include a readable copy of the attribution notices contained
114
+ within such NOTICE file, excluding those notices that do not
115
+ pertain to any part of the Derivative Works, in at least one
116
+ of the following places: within a NOTICE text file distributed
117
+ as part of the Derivative Works; within the Source form or
118
+ documentation, if provided along with the Derivative Works; or,
119
+ within a display generated by the Derivative Works, if and
120
+ wherever such third-party notices normally appear. The contents
121
+ of the NOTICE file are for informational purposes only and
122
+ do not modify the License. You may add Your own attribution
123
+ notices within Derivative Works that You distribute, alongside
124
+ or as an addendum to the NOTICE text from the Work, provided
125
+ that such additional attribution notices cannot be construed
126
+ as modifying the License.
127
+
128
+ You may add Your own copyright statement to Your modifications and
129
+ may provide additional or different license terms and conditions
130
+ for use, reproduction, or distribution of Your modifications, or
131
+ for any such Derivative Works as a whole, provided Your use,
132
+ reproduction, and distribution of the Work otherwise complies with
133
+ the conditions stated in this License.
134
+
135
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
136
+ any Contribution intentionally submitted for inclusion in the Work
137
+ by You to the Licensor shall be under the terms and conditions of
138
+ this License, without any additional terms or conditions.
139
+ Notwithstanding the above, nothing herein shall supersede or modify
140
+ the terms of any separate license agreement you may have executed
141
+ with Licensor regarding such Contributions.
142
+
143
+ 6. Trademarks. This License does not grant permission to use the trade
144
+ names, trademarks, service marks, or product names of the Licensor,
145
+ except as required for reasonable and customary use in describing the
146
+ origin of the Work and reproducing the content of the NOTICE file.
147
+
148
+ 7. Disclaimer of Warranty. Unless required by applicable law or
149
+ agreed to in writing, Licensor provides the Work (and each
150
+ Contributor provides its Contributions) on an "AS IS" BASIS,
151
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
152
+ implied, including, without limitation, any warranties or conditions
153
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
154
+ PARTICULAR PURPOSE. You are solely responsible for determining the
155
+ appropriateness of using or redistributing the Work and assume any
156
+ risks associated with Your exercise of permissions under this License.
157
+
158
+ 8. Limitation of Liability. In no event and under no legal theory,
159
+ whether in tort (including negligence), contract, or otherwise,
160
+ unless required by applicable law (such as deliberate and grossly
161
+ negligent acts) or agreed to in writing, shall any Contributor be
162
+ liable to You for damages, including any direct, indirect, special,
163
+ incidental, or consequential damages of any character arising as a
164
+ result of this License or out of the use or inability to use the
165
+ Work (including but not limited to damages for loss of goodwill,
166
+ work stoppage, computer failure or malfunction, or any and all
167
+ other commercial damages or losses), even if such Contributor
168
+ has been advised of the possibility of such damages.
169
+
170
+ 9. Accepting Warranty or Additional Liability. While redistributing
171
+ the Work or Derivative Works thereof, You may choose to offer,
172
+ and charge a fee for, acceptance of support, warranty, indemnity,
173
+ or other liability obligations and/or rights consistent with this
174
+ License. However, in accepting such obligations, You may act only
175
+ on Your own behalf and on Your sole responsibility, not on behalf
176
+ of any other Contributor, and only if You agree to indemnify,
177
+ defend, and hold each Contributor harmless for any liability
178
+ incurred by, or claims asserted against, such Contributor by reason
179
+ of your accepting any such warranty or additional liability.
180
+
181
+ END OF TERMS AND CONDITIONS
182
+
183
+ APPENDIX: How to apply the Apache License to your work.
184
+
185
+ To apply the Apache License to your work, attach the following
186
+ boilerplate notice, with the fields enclosed by brackets "{}"
187
+ replaced with your own identifying information. (Don't include
188
+ the brackets!) The text should be enclosed in the appropriate
189
+ comment syntax for the file format. We also recommend that a
190
+ file or class name and description of purpose be included on the
191
+ same "printed page" as the copyright notice for easier
192
+ identification within third-party archives.
193
+
194
+ Copyright {yyyy} {name of copyright owner}
195
+
196
+ Licensed under the Apache License, Version 2.0 (the "License");
197
+ you may not use this file except in compliance with the License.
198
+ You may obtain a copy of the License at
199
+
200
+ http://www.apache.org/licenses/LICENSE-2.0
201
+
202
+ Unless required by applicable law or agreed to in writing, software
203
+ distributed under the License is distributed on an "AS IS" BASIS,
204
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
205
+ See the License for the specific language governing permissions and
206
+ limitations under the License.
207
+
208
+ = = = = =
209
+
210
+ Parts of typeshed are licensed under different licenses (like the MIT
211
+ license), reproduced below.
212
+
213
+ = = = = =
214
+
215
+ The MIT License
216
+
217
+ Copyright (c) 2015 Jukka Lehtosalo and contributors
218
+
219
+ Permission is hereby granted, free of charge, to any person obtaining a
220
+ copy of this software and associated documentation files (the "Software"),
221
+ to deal in the Software without restriction, including without limitation
222
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
223
+ and/or sell copies of the Software, and to permit persons to whom the
224
+ Software is furnished to do so, subject to the following conditions:
225
+
226
+ The above copyright notice and this permission notice shall be included in
227
+ all copies or substantial portions of the Software.
228
+
229
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
230
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
231
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
232
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
233
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
234
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
235
+ DEALINGS IN THE SOFTWARE.
236
+
237
+ = = = = =
@@ -0,0 +1 @@
1
+ webtest-stubs
@@ -0,0 +1,3 @@
1
+ version = "3.0.*"
2
+ upstream-repository = "https://github.com/Pylons/webtest"
3
+ dependencies = ["beautifulsoup4", "types-waitress", "types-WebOb"]
@@ -0,0 +1,14 @@
1
+ from webtest.app import AppError as AppError, TestApp as TestApp, TestRequest as TestRequest
2
+ from webtest.forms import (
3
+ Checkbox as Checkbox,
4
+ Field as Field,
5
+ Form as Form,
6
+ Hidden as Hidden,
7
+ Radio as Radio,
8
+ Select as Select,
9
+ Submit as Submit,
10
+ Text as Text,
11
+ Textarea as Textarea,
12
+ Upload as Upload,
13
+ )
14
+ from webtest.response import TestResponse as TestResponse
webtest-stubs/app.pyi ADDED
@@ -0,0 +1,206 @@
1
+ import json
2
+ from _typeshed import SupportsItems, SupportsKeysAndGetItem
3
+ from _typeshed.wsgi import WSGIApplication, WSGIEnvironment
4
+ from collections.abc import Iterable, Sequence
5
+ from http.cookiejar import CookieJar, DefaultCookiePolicy
6
+ from typing import Any, Generic, Literal, TypeAlias, TypeVar
7
+
8
+ from webob.request import BaseRequest
9
+ from webtest.forms import File, Upload
10
+ from webtest.response import TestResponse
11
+
12
+ # NOTE: While it is possible to pass different kinds of values depending on
13
+ # the exact configuration of the request, it seems more robust to
14
+ # restrict them to the types that are supported by all code paths.
15
+ # I don't expect anyone to try to pass different kinds of values
16
+ # in a non-JSON request.
17
+ _ParamValue: TypeAlias = File | Upload | int | bytes | str
18
+ _Params: TypeAlias = SupportsItems[str | bytes, _ParamValue] | Sequence[tuple[str | bytes, _ParamValue]]
19
+ # NOTE: Using `Collection` rather than `Iterable` would probably be slightly
20
+ # safer since WebTest will check this parameter for truthyness. But since
21
+ # objects are truthy by default, this should only lead to issues in truly
22
+ # exotic cases.
23
+ _ExtraEnviron: TypeAlias = SupportsKeysAndGetItem[str, Any] | Iterable[tuple[str, Any]]
24
+ _Files: TypeAlias = Sequence[tuple[str, str] | tuple[str, str, bytes]]
25
+ _AppT = TypeVar("_AppT", bound=WSGIApplication, default=WSGIApplication)
26
+
27
+ __all__ = ["TestApp", "TestRequest"]
28
+
29
+ class AppError(Exception):
30
+ def __init__(self, message: str, *args: object) -> None: ...
31
+
32
+ class CookiePolicy(DefaultCookiePolicy): ...
33
+
34
+ class TestRequest(BaseRequest):
35
+ ResponseClass: type[TestResponse]
36
+ __test__: Literal[False]
37
+
38
+ class TestApp(Generic[_AppT]):
39
+ RequestClass: type[TestRequest]
40
+ app: _AppT
41
+ lint: bool
42
+ relative_to: str | None
43
+ extra_environ: WSGIEnvironment
44
+ use_unicode: bool
45
+ cookiejar: CookieJar
46
+ JSONEncoder: json.JSONEncoder
47
+ __test__: Literal[False]
48
+ def __init__(
49
+ self,
50
+ app: _AppT,
51
+ # NOTE: this extra_environ is different from the others and needs to
52
+ # support __delitem__, it seems easiest to just treat this like
53
+ # a regular WSGIEnvironment. The docs also say that this should
54
+ # be a dictionary.
55
+ extra_environ: WSGIEnvironment | None = None,
56
+ relative_to: str | None = None,
57
+ use_unicode: bool = True,
58
+ cookiejar: CookieJar | None = None,
59
+ parser_features: Sequence[str] | str | None = None,
60
+ json_encoder: json.JSONEncoder | None = None,
61
+ lint: bool = True,
62
+ ) -> None: ...
63
+ def get_authorization(self) -> tuple[str, str | tuple[str, str]]: ...
64
+ def set_authorization(self, value: tuple[str, str | tuple[str, str]]) -> None: ...
65
+
66
+ @property
67
+ def authorization(self) -> tuple[str, str | tuple[str, str]]: ...
68
+ @authorization.setter
69
+ def authorization(self, value: tuple[str, str | tuple[str, str]]) -> None: ...
70
+
71
+ @property
72
+ def cookies(self) -> dict[str, str | None]: ...
73
+ def set_cookie(self, name: str, value: str | None) -> None: ...
74
+ def reset(self) -> None: ...
75
+ def set_parser_features(self, parser_features: Sequence[str] | str) -> None: ...
76
+ def get(
77
+ self,
78
+ url: str,
79
+ params: _Params | str | None = None,
80
+ headers: dict[str, str] | None = None,
81
+ extra_environ: _ExtraEnviron | None = None,
82
+ status: int | str | None = None,
83
+ expect_errors: bool = False,
84
+ xhr: bool = False,
85
+ ) -> TestResponse: ...
86
+ def post(
87
+ self,
88
+ url: str,
89
+ params: _Params | str = "",
90
+ headers: dict[str, str] | None = None,
91
+ extra_environ: _ExtraEnviron | None = None,
92
+ status: int | str | None = None,
93
+ upload_files: _Files | None = None,
94
+ expect_errors: bool = False,
95
+ content_type: str | None = None,
96
+ xhr: bool = False,
97
+ ) -> TestResponse: ...
98
+ def put(
99
+ self,
100
+ url: str,
101
+ params: _Params | str = "",
102
+ headers: dict[str, str] | None = None,
103
+ extra_environ: _ExtraEnviron | None = None,
104
+ status: int | str | None = None,
105
+ upload_files: _Files | None = None,
106
+ expect_errors: bool = False,
107
+ content_type: str | None = None,
108
+ xhr: bool = False,
109
+ ) -> TestResponse: ...
110
+ def patch(
111
+ self,
112
+ url: str,
113
+ params: _Params | str = "",
114
+ headers: dict[str, str] | None = None,
115
+ extra_environ: _ExtraEnviron | None = None,
116
+ status: int | str | None = None,
117
+ upload_files: _Files | None = None,
118
+ expect_errors: bool = False,
119
+ content_type: str | None = None,
120
+ xhr: bool = False,
121
+ ) -> TestResponse: ...
122
+ def delete(
123
+ self,
124
+ url: str,
125
+ params: _Params | str = "",
126
+ headers: dict[str, str] | None = None,
127
+ extra_environ: _ExtraEnviron | None = None,
128
+ status: int | str | None = None,
129
+ expect_errors: bool = False,
130
+ content_type: str | None = None,
131
+ xhr: bool = False,
132
+ ) -> TestResponse: ...
133
+ def options(
134
+ self,
135
+ url: str,
136
+ headers: dict[str, str] | None = None,
137
+ extra_environ: _ExtraEnviron | None = None,
138
+ status: int | str | None = None,
139
+ expect_errors: bool = False,
140
+ xhr: bool = False,
141
+ ) -> TestResponse: ...
142
+ def head(
143
+ self,
144
+ url: str,
145
+ params: _Params | str | None = None,
146
+ headers: dict[str, str] | None = None,
147
+ extra_environ: _ExtraEnviron | None = None,
148
+ status: int | str | None = None,
149
+ expect_errors: bool = False,
150
+ xhr: bool = False,
151
+ ) -> TestResponse: ...
152
+ def post_json(
153
+ self,
154
+ url: str,
155
+ params: Any = ...,
156
+ *,
157
+ headers: dict[str, str] | None = None,
158
+ extra_environ: _ExtraEnviron | None = None,
159
+ status: int | str | None = None,
160
+ expect_errors: bool = False,
161
+ content_type: str | None = None,
162
+ xhr: bool = False,
163
+ ) -> TestResponse: ...
164
+ def put_json(
165
+ self,
166
+ url: str,
167
+ params: Any = ...,
168
+ *,
169
+ headers: dict[str, str] | None = None,
170
+ extra_environ: _ExtraEnviron | None = None,
171
+ status: int | str | None = None,
172
+ expect_errors: bool = False,
173
+ content_type: str | None = None,
174
+ xhr: bool = False,
175
+ ) -> TestResponse: ...
176
+ def patch_json(
177
+ self,
178
+ url: str,
179
+ params: Any = ...,
180
+ *,
181
+ headers: dict[str, str] | None = None,
182
+ extra_environ: _ExtraEnviron | None = None,
183
+ status: int | str | None = None,
184
+ expect_errors: bool = False,
185
+ content_type: str | None = None,
186
+ xhr: bool = False,
187
+ ) -> TestResponse: ...
188
+ def delete_json(
189
+ self,
190
+ url: str,
191
+ params: Any = ...,
192
+ *,
193
+ headers: dict[str, str] | None = None,
194
+ extra_environ: _ExtraEnviron | None = None,
195
+ status: int | str | None = None,
196
+ expect_errors: bool = False,
197
+ content_type: str | None = None,
198
+ xhr: bool = False,
199
+ ) -> TestResponse: ...
200
+ def encode_multipart(self, params: Iterable[tuple[str | bytes, _ParamValue]], files: _Files) -> tuple[str, bytes]: ...
201
+ def request(
202
+ self, url_or_req: str | TestRequest, status: int | str | None = None, expect_errors: bool = False, **req_params: Any
203
+ ) -> TestResponse: ...
204
+ def do_request(
205
+ self, req: TestRequest, status: int | str | None = None, expect_errors: bool | None = None
206
+ ) -> TestResponse: ...
@@ -0,0 +1,22 @@
1
+ from _typeshed import StrOrBytesPath
2
+ from _typeshed.wsgi import StartResponse, WSGIEnvironment
3
+ from collections.abc import Iterable
4
+ from typing import TypedDict, type_check_only
5
+ from typing_extensions import Unpack
6
+
7
+ @type_check_only
8
+ class _DebugAppParams(TypedDict, total=False):
9
+ form: StrOrBytesPath | bytes | None
10
+ show_form: bool
11
+
12
+ __all__ = ["DebugApp", "make_debug_app"]
13
+
14
+ class DebugApp:
15
+ form: bytes | None
16
+ show_form: bool
17
+ def __init__(self, form: StrOrBytesPath | bytes | None = None, show_form: bool = False) -> None: ...
18
+ def __call__(self, environ: WSGIEnvironment, start_response: StartResponse) -> Iterable[bytes]: ...
19
+
20
+ debug_app: DebugApp
21
+
22
+ def make_debug_app(global_conf: object, **local_conf: Unpack[_DebugAppParams]) -> DebugApp: ...
@@ -0,0 +1,191 @@
1
+ from collections.abc import Collection, Generator, Iterable, Sequence
2
+ from typing import Any, TypeAlias, TypedDict, TypeVar, overload, type_check_only
3
+
4
+ from bs4 import BeautifulSoup
5
+ from webtest.response import TestResponse
6
+
7
+ _T = TypeVar("_T")
8
+
9
+ @type_check_only
10
+ class _Classes(TypedDict):
11
+ submit: type[Submit]
12
+ button: type[Submit]
13
+ image: type[Submit]
14
+ multiple_select: type[MultipleSelect]
15
+ select: type[Select]
16
+ hidden: type[Hidden]
17
+ file: type[File]
18
+ text: type[Text]
19
+ search: type[Text]
20
+ email: type[Email]
21
+ password: type[Text]
22
+ checkbox: type[Checkbox]
23
+ textarea: type[Textarea]
24
+ radio: type[Radio]
25
+
26
+ # NOTE: It seems unergonomic having to put isinstance checks everywhere
27
+ # in your test code where you're accessing a form field, so we
28
+ # return `Any` for now. What we would really like to use here is
29
+ # `AnyOf`, but that doesn't exist yet.
30
+ _AnyField: TypeAlias = Any
31
+
32
+ class NoValue: ...
33
+
34
+ class Upload:
35
+ filename: str
36
+ content: bytes | None
37
+ content_type: str | None
38
+ def __init__(self, filename: str, content: bytes | None = None, content_type: str | None = None) -> None: ...
39
+ def __iter__(self) -> Generator[str | bytes]: ...
40
+
41
+ class Field:
42
+ classes: _Classes
43
+ form: Form
44
+ tag: str
45
+ name: str
46
+ pos: int
47
+ id: str
48
+ attrs: dict[str, str]
49
+ def __init__(
50
+ self, form: Form, tag: str, name: str, pos: int, value: str | None = None, id: str | None = None, **attrs: str
51
+ ) -> None: ...
52
+ def value__get(self) -> str: ...
53
+ def value__set(self, value: str | None) -> None: ...
54
+
55
+ @property
56
+ def value(self) -> str: ...
57
+ @value.setter
58
+ def value(self, value: str | None) -> None: ...
59
+
60
+ def force_value(self, value: str | None) -> None: ...
61
+
62
+ class Select(Field):
63
+ options: list[tuple[str, bool, str]]
64
+ optionPositions: list[int]
65
+ selectedIndex: int | None
66
+
67
+ # NOTE: Even though it's safe to pass any object into text, I don't
68
+ # think that follows the spirit of this argument and is more
69
+ # likely a consequence of reusing the same utility function
70
+ # in order to handle bytes for Py2 compat.
71
+ @overload
72
+ def select(self, value: None, text: str | bytes) -> None: ...
73
+ @overload
74
+ def select(self, value: None = None, *, text: str | bytes) -> None: ...
75
+ @overload
76
+ def select(self, value: object, text: None = None) -> None: ...
77
+
78
+ def value__get(self) -> str: ...
79
+ def value__set(self, value: object | None) -> None: ...
80
+
81
+ @property
82
+ def value(self) -> str: ...
83
+ @value.setter
84
+ def value(self, value: object | None) -> None: ...
85
+
86
+ class MultipleSelect(Field):
87
+ options: list[tuple[str, bool, str]]
88
+ selectedIndices: list[int]
89
+
90
+ @overload
91
+ def select_multiple(self, value: None, texts: Iterable[str | bytes]) -> None: ...
92
+ @overload
93
+ def select_multiple(self, value: None = None, *, texts: Iterable[str | bytes]) -> None: ...
94
+ @overload
95
+ def select_multiple(self, value: Collection[object], texts: None = None) -> None: ...
96
+
97
+ def value__get(self) -> list[str] | None: ... # type: ignore[override]
98
+ def value__set(self, values: Collection[object] | None) -> None: ...
99
+
100
+ @property # type: ignore[override]
101
+ def value(self) -> list[str] | None: ...
102
+ @value.setter
103
+ def value(self, value: Collection[object] | None) -> None: ...
104
+
105
+ # NOTE: Since unlike setting the value normally this doesn't perform
106
+ # any kind of type conversion, we're better off only allowing
107
+ # what `value__get` is supposed to be able to return.
108
+ def force_value(self, values: list[str] | None) -> None: ... # type: ignore[override]
109
+
110
+ class Radio(Select): ...
111
+
112
+ class Checkbox(Field):
113
+ def value__get(self) -> str | None: ... # type: ignore[override]
114
+ def value__set(self, value: object) -> None: ...
115
+
116
+ @property # type: ignore[override]
117
+ def value(self) -> str | None: ...
118
+ @value.setter
119
+ def value(self, value: object) -> None: ...
120
+
121
+ def checked__get(self) -> bool: ...
122
+ def checked__set(self, value: object) -> None: ...
123
+
124
+ @property
125
+ def checked(self) -> bool: ...
126
+ @checked.setter
127
+ def checked(self, value: object) -> None: ...
128
+
129
+ class Text(Field): ...
130
+ class Email(Field): ...
131
+ class File(Field): ...
132
+ class Textarea(Text): ...
133
+ class Hidden(Text): ...
134
+
135
+ class Submit(Field):
136
+ def value__get(self) -> None: ... # type: ignore[override]
137
+ @property # type: ignore[misc]
138
+ def value(self) -> None: ... # type: ignore[override]
139
+ def value_if_submitted(self) -> str: ...
140
+
141
+ class Form:
142
+ FieldClass: type[Field]
143
+ response: TestResponse
144
+ text: str
145
+ html: BeautifulSoup
146
+ action: str
147
+ method: str
148
+ id: str | None
149
+ enctype: str
150
+ field_order: list[tuple[str, Field]]
151
+ fields: dict[str, list[Field]]
152
+ def __init__(self, response: TestResponse, text: str, parser_features: Sequence[str] | str = "html.parser") -> None: ...
153
+ # NOTE: Technically it is only safe to pass `str | None` for most fields
154
+ # but this method is not really usable if we don't lift this
155
+ # restriction, we just have to assume people know what they
156
+ # are doing
157
+ def __setitem__(self, name: str, value: Any | None) -> None: ...
158
+ def set(self, name: str, value: Any | None, index: int | None = None) -> None: ...
159
+ def __getitem__(self, name: str) -> _AnyField: ...
160
+
161
+ @overload
162
+ def get(self, name: str, index: int | None = None) -> _AnyField: ...
163
+ @overload
164
+ def get(self, name: str, index: int | None, default: _T) -> _AnyField | _T: ...
165
+ @overload
166
+ def get(self, name: str, index: int | None = None, *, default: _T) -> _AnyField | _T: ...
167
+
168
+ @overload
169
+ def select(self, name: str, value: None, text: str | bytes, index: int | None = None) -> None: ...
170
+ @overload
171
+ def select(self, name: str, value: None = None, *, text: str | bytes, index: int | None = None) -> None: ...
172
+ @overload
173
+ def select(self, name: str, value: object, text: None = None, index: int | None = None) -> None: ...
174
+
175
+ @overload
176
+ def select_multiple(self, name: str, value: None, texts: Iterable[str | bytes], index: int | None = None) -> None: ...
177
+ @overload
178
+ def select_multiple(
179
+ self, name: str, value: None = None, *, texts: Iterable[str | bytes], index: int | None = None
180
+ ) -> None: ...
181
+ @overload
182
+ def select_multiple(self, name: str, value: Iterable[object], texts: None = None, index: int | None = None) -> None: ...
183
+
184
+ def submit(
185
+ self, name: str | None = None, index: int | None = None, value: str | None = None, **args: Any
186
+ ) -> TestResponse: ...
187
+ def lint(self) -> None: ...
188
+ def upload_fields(self) -> list[tuple[str, str] | tuple[str, str, bytes]]: ...
189
+ def submit_fields(
190
+ self, name: str | None = None, index: int | None = None, submit_value: str | None = None
191
+ ) -> list[tuple[str, str]]: ...
webtest-stubs/http.pyi ADDED
@@ -0,0 +1,30 @@
1
+ from _typeshed import Incomplete
2
+ from _typeshed.wsgi import StartResponse, WSGIApplication, WSGIEnvironment
3
+ from collections.abc import Iterable
4
+ from threading import Thread
5
+ from typing import Literal, TypeAlias
6
+ from typing_extensions import Self
7
+
8
+ from waitress.server import TcpWSGIServer
9
+
10
+ # NOTE: We may never really be able to complete this, since `create`
11
+ # invokes `cls.__init__` which is exempt from LSP violations
12
+ # unless we get something like `KwArgsOf[cls.__init__]`.
13
+ _WSGIServerParams: TypeAlias = Incomplete
14
+
15
+ def get_free_port() -> tuple[str, int]: ...
16
+ def check_server(host: str, port: int, path_info: str = "/", timeout: float = 3, retries: int = 30) -> int: ...
17
+
18
+ class StopableWSGIServer(TcpWSGIServer):
19
+ was_shutdown: bool
20
+ runner: Thread
21
+ test_app: WSGIApplication
22
+ application_url: str
23
+ def wrapper(self, environ: WSGIEnvironment, start_response: StartResponse) -> Iterable[bytes]: ...
24
+ def run(self) -> None: ...
25
+ def shutdown(self, debug: bool = False) -> Literal[True]: ...
26
+ # NOTE: This has the same keyword arguments as cls.__init__, which
27
+ # we can't express
28
+ @classmethod
29
+ def create(cls, application: WSGIApplication, **kwargs: _WSGIServerParams) -> Self: ...
30
+ def wait(self, retries: int = 30) -> bool: ...
webtest-stubs/py.typed ADDED
File without changes
@@ -0,0 +1,93 @@
1
+ import re
2
+ from _typeshed.wsgi import WSGIApplication
3
+ from collections.abc import Callable, Mapping, Sequence
4
+ from typing import Any, Literal, TypeAlias, TypedDict, overload, type_check_only
5
+ from typing_extensions import Unpack
6
+ from xml.etree import ElementTree
7
+
8
+ from bs4 import BeautifulSoup
9
+ from webob import Response
10
+ from webtest.app import TestApp, TestRequest, _Files
11
+ from webtest.forms import Form
12
+
13
+ _Pattern: TypeAlias = str | bytes | re.Pattern[str] | Callable[[str], bool]
14
+ # NOTE: These are optional dependencies, so we don't want to depend on them
15
+ # in the stubs either. Also there are no stubs for pyquery anyways.
16
+ _PyQuery: TypeAlias = Any
17
+ _PyQueryParams: TypeAlias = Any
18
+ _LxmlElement: TypeAlias = Any
19
+
20
+ @type_check_only
21
+ class _GetParams(TypedDict, total=False):
22
+ params: Mapping[str, str] | str
23
+ headers: Mapping[str, str]
24
+ extra_environ: Mapping[str, Any]
25
+ status: int | str | None
26
+ expect_errors: bool
27
+ xhr: bool
28
+
29
+ @type_check_only
30
+ class _PostParams(_GetParams, total=False):
31
+ upload_files: _Files
32
+ content_type: str
33
+
34
+ class TestResponse(Response):
35
+ # NOTE: The way WebTest creates reponses the request is always set
36
+ # we could've used `MaybeNone`, but it seems more pragmatic
37
+ # to just assume that this is always set.
38
+ request: TestRequest # type: ignore[assignment]
39
+ app: WSGIApplication
40
+ test_app: TestApp
41
+ parser_features: str | Sequence[str]
42
+ __test__: Literal[False]
43
+ @property
44
+ def forms(self) -> dict[str | int, Form]: ...
45
+ @property
46
+ def form(self) -> Form: ...
47
+ @property
48
+ def testbody(self) -> str: ...
49
+ def follow(self, **kw: Unpack[_GetParams]) -> TestResponse: ...
50
+ def maybe_follow(self, **kw: Unpack[_GetParams]) -> TestResponse: ...
51
+ def click(
52
+ self,
53
+ description: _Pattern | None = None,
54
+ linkid: _Pattern | None = None,
55
+ href: _Pattern | None = None,
56
+ index: int | None = None,
57
+ verbose: bool = False,
58
+ extra_environ: dict[str, Any] | None = None,
59
+ ) -> TestResponse: ...
60
+ def clickbutton(
61
+ self,
62
+ description: _Pattern | None = None,
63
+ buttonid: _Pattern | None = None,
64
+ href: _Pattern | None = None,
65
+ onclick: str | None = None,
66
+ index: int | None = None,
67
+ verbose: bool = False,
68
+ ) -> TestResponse: ...
69
+
70
+ @overload
71
+ def goto(self, href: str, method: Literal["get"] = "get", **args: Unpack[_GetParams]) -> TestResponse: ...
72
+ @overload
73
+ def goto(self, href: str, method: Literal["post"], **args: Unpack[_PostParams]) -> TestResponse: ...
74
+
75
+ @property
76
+ def normal_body(self) -> bytes: ...
77
+ @property
78
+ def unicode_normal_body(self) -> str: ...
79
+ def __contains__(self, s: str) -> bool: ...
80
+ def mustcontain(self, *strings: str, no: Sequence[str] | str = ...) -> None: ...
81
+ @property
82
+ def html(self) -> BeautifulSoup: ...
83
+ @property
84
+ def xml(self) -> ElementTree.Element: ...
85
+ @property
86
+ def lxml(self) -> _LxmlElement: ...
87
+ @property
88
+ def json(self) -> Any: ...
89
+ @property
90
+ def pyquery(self) -> _PyQuery: ...
91
+ def PyQuery(self, **kwargs: _PyQueryParams) -> _PyQuery: ...
92
+ def showbrowser(self) -> None: ...
93
+ def __str__(self) -> str: ... # type: ignore[override] # noqa: Y029