|
| 1 | +import json |
| 2 | +from _typeshed.wsgi import WSGIApplication |
| 3 | +from collections.abc import Mapping, Sequence |
| 4 | +from http.cookiejar import CookieJar, DefaultCookiePolicy |
| 5 | +from typing import Any, Generic, Literal, TypeVar |
| 6 | +from typing_extensions import TypeAlias |
| 7 | + |
| 8 | +from webob.request import BaseRequest |
| 9 | +from webtest.response import TestResponse |
| 10 | + |
| 11 | +_Files: TypeAlias = Sequence[tuple[str, str] | tuple[str, str, bytes]] |
| 12 | +_AppT = TypeVar("_AppT", bound=WSGIApplication, default=WSGIApplication) |
| 13 | + |
| 14 | +__all__ = ["TestApp", "TestRequest"] |
| 15 | + |
| 16 | +class AppError(Exception): |
| 17 | + def __init__(self, message: str, *args: object) -> None: ... |
| 18 | + |
| 19 | +class CookiePolicy(DefaultCookiePolicy): ... |
| 20 | + |
| 21 | +class TestRequest(BaseRequest): |
| 22 | + ResponseClass: type[TestResponse] |
| 23 | + __test__: Literal[False] |
| 24 | + |
| 25 | +class TestApp(Generic[_AppT]): |
| 26 | + RequestClass: type[TestRequest] |
| 27 | + app: _AppT |
| 28 | + lint: bool |
| 29 | + relative_to: str | None |
| 30 | + extra_environ: dict[str, Any] |
| 31 | + use_unicode: bool |
| 32 | + cookiejar: CookieJar |
| 33 | + JSONEncoder: json.JSONEncoder |
| 34 | + __test__: Literal[False] |
| 35 | + def __init__( |
| 36 | + self, |
| 37 | + app: _AppT, |
| 38 | + extra_environ: dict[str, Any] | None = None, |
| 39 | + relative_to: str | None = None, |
| 40 | + use_unicode: bool = True, |
| 41 | + cookiejar: CookieJar | None = None, |
| 42 | + parser_features: Sequence[str] | str | None = None, |
| 43 | + json_encoder: json.JSONEncoder | None = None, |
| 44 | + lint: bool = True, |
| 45 | + ) -> None: ... |
| 46 | + def get_authorization(self) -> tuple[str, str | tuple[str, str]]: ... |
| 47 | + def set_authorization(self, value: tuple[str, str | tuple[str, str]]) -> None: ... |
| 48 | + @property |
| 49 | + def authorization(self) -> tuple[str, str | tuple[str, str]]: ... |
| 50 | + @authorization.setter |
| 51 | + def authorization(self, value: tuple[str, str | tuple[str, str]]) -> None: ... |
| 52 | + @property |
| 53 | + def cookies(self) -> dict[str, str | None]: ... |
| 54 | + def set_cookie(self, name: str, value: str | None) -> None: ... |
| 55 | + def reset(self) -> None: ... |
| 56 | + def set_parser_features(self, parser_features: Sequence[str] | str) -> None: ... |
| 57 | + def get( |
| 58 | + self, |
| 59 | + url: str, |
| 60 | + params: Mapping[str, str] | str | None = None, |
| 61 | + headers: Mapping[str, str] | None = None, |
| 62 | + extra_environ: Mapping[str, Any] | None = None, |
| 63 | + status: int | str | None = None, |
| 64 | + expect_errors: bool = False, |
| 65 | + xhr: bool = False, |
| 66 | + ) -> TestResponse: ... |
| 67 | + def post( |
| 68 | + self, |
| 69 | + url: str, |
| 70 | + params: Mapping[str, str] | str = "", |
| 71 | + headers: Mapping[str, str] | None = None, |
| 72 | + extra_environ: Mapping[str, Any] | None = None, |
| 73 | + status: int | str | None = None, |
| 74 | + upload_files: _Files | None = None, |
| 75 | + expect_errors: bool = False, |
| 76 | + content_type: str | None = None, |
| 77 | + xhr: bool = False, |
| 78 | + ) -> TestResponse: ... |
| 79 | + def put( |
| 80 | + self, |
| 81 | + url: str, |
| 82 | + params: Mapping[str, str] | str = "", |
| 83 | + headers: Mapping[str, str] | None = None, |
| 84 | + extra_environ: Mapping[str, Any] | None = None, |
| 85 | + status: int | str | None = None, |
| 86 | + upload_files: _Files | None = None, |
| 87 | + expect_errors: bool = False, |
| 88 | + content_type: str | None = None, |
| 89 | + xhr: bool = False, |
| 90 | + ) -> TestResponse: ... |
| 91 | + def patch( |
| 92 | + self, |
| 93 | + url: str, |
| 94 | + params: Mapping[str, str] | str = "", |
| 95 | + headers: Mapping[str, str] | None = None, |
| 96 | + extra_environ: Mapping[str, Any] | None = None, |
| 97 | + status: int | str | None = None, |
| 98 | + upload_files: _Files | None = None, |
| 99 | + expect_errors: bool = False, |
| 100 | + content_type: str | None = None, |
| 101 | + xhr: bool = False, |
| 102 | + ) -> TestResponse: ... |
| 103 | + def delete( |
| 104 | + self, |
| 105 | + url: str, |
| 106 | + params: Mapping[str, str] | str = "", |
| 107 | + headers: Mapping[str, str] | None = None, |
| 108 | + extra_environ: Mapping[str, Any] | None = None, |
| 109 | + status: int | str | None = None, |
| 110 | + expect_errors: bool = False, |
| 111 | + content_type: str | None = None, |
| 112 | + xhr: bool = False, |
| 113 | + ) -> TestResponse: ... |
| 114 | + def options( |
| 115 | + self, |
| 116 | + url: str, |
| 117 | + headers: Mapping[str, str] | None = None, |
| 118 | + extra_environ: Mapping[str, Any] | None = None, |
| 119 | + status: int | str | None = None, |
| 120 | + expect_errors: bool = False, |
| 121 | + xhr: bool = False, |
| 122 | + ) -> TestResponse: ... |
| 123 | + def head( |
| 124 | + self, |
| 125 | + url: str, |
| 126 | + params: Mapping[str, str] | str | None = None, |
| 127 | + headers: Mapping[str, str] | None = None, |
| 128 | + extra_environ: Mapping[str, Any] | None = None, |
| 129 | + status: int | str | None = None, |
| 130 | + expect_errors: bool = False, |
| 131 | + xhr: bool = False, |
| 132 | + ) -> TestResponse: ... |
| 133 | + def post_json( |
| 134 | + self, |
| 135 | + url: str, |
| 136 | + params: Any = ..., |
| 137 | + *, |
| 138 | + headers: Mapping[str, str] | None = None, |
| 139 | + extra_environ: Mapping[str, Any] | None = None, |
| 140 | + status: int | str | None = None, |
| 141 | + expect_errors: bool = False, |
| 142 | + content_type: str | None = None, |
| 143 | + xhr: bool = False, |
| 144 | + ) -> TestResponse: ... |
| 145 | + def put_json( |
| 146 | + self, |
| 147 | + url: str, |
| 148 | + params: Any = ..., |
| 149 | + *, |
| 150 | + headers: Mapping[str, str] | None = None, |
| 151 | + extra_environ: Mapping[str, Any] | None = None, |
| 152 | + status: int | str | None = None, |
| 153 | + expect_errors: bool = False, |
| 154 | + content_type: str | None = None, |
| 155 | + xhr: bool = False, |
| 156 | + ) -> TestResponse: ... |
| 157 | + def patch_json( |
| 158 | + self, |
| 159 | + url: str, |
| 160 | + params: Any = ..., |
| 161 | + *, |
| 162 | + headers: Mapping[str, str] | None = None, |
| 163 | + extra_environ: Mapping[str, Any] | None = None, |
| 164 | + status: int | str | None = None, |
| 165 | + expect_errors: bool = False, |
| 166 | + content_type: str | None = None, |
| 167 | + xhr: bool = False, |
| 168 | + ) -> TestResponse: ... |
| 169 | + def delete_json( |
| 170 | + self, |
| 171 | + url: str, |
| 172 | + params: Any = ..., |
| 173 | + *, |
| 174 | + headers: Mapping[str, str] | None = None, |
| 175 | + extra_environ: Mapping[str, Any] | None = None, |
| 176 | + status: int | str | None = None, |
| 177 | + expect_errors: bool = False, |
| 178 | + content_type: str | None = None, |
| 179 | + xhr: bool = False, |
| 180 | + ) -> TestResponse: ... |
| 181 | + def encode_multipart(self, params: Sequence[tuple[str, str]], files: _Files) -> tuple[str, bytes]: ... |
| 182 | + def request( |
| 183 | + self, url_or_req: str | TestRequest, status: int | str | None = None, expect_errors: bool = False, **req_params: Any |
| 184 | + ) -> TestResponse: ... |
| 185 | + def do_request( |
| 186 | + self, req: TestRequest, status: int | str | None = None, expect_errors: bool | None = None |
| 187 | + ) -> TestResponse: ... |
0 commit comments