- Sort Score
- Result 10 results
- Languages All
Results 291 - 300 of 1,379 for def2 (0.03 sec)
-
tests/test_swagger_ui_init_oauth.py
swagger_ui_init_oauth = {"clientId": "the-foo-clients", "appName": "The Predendapp"} app = FastAPI(swagger_ui_init_oauth=swagger_ui_init_oauth) @app.get("/items/") async def read_items(): return {"id": "foo"} client = TestClient(app) def test_swagger_ui(): response = client.get("/docs") assert response.status_code == 200, response.text print(response.text) assert "ui.initOAuth" in response.text
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sun Aug 09 10:54:05 UTC 2020 - 718 bytes - Viewed (0) -
tests/test_tutorial/test_additional_status_codes/test_tutorial001_an_py310.py
import pytest from fastapi.testclient import TestClient from ...utils import needs_py310 @pytest.fixture(name="client") def get_client(): from docs_src.additional_status_codes.tutorial001_an_py310 import app client = TestClient(app) return client @needs_py310 def test_update(client: TestClient): response = client.put("/items/foo", json={"name": "Wrestlers"}) assert response.status_code == 200, response.text
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sat Mar 18 12:29:59 UTC 2023 - 741 bytes - Viewed (0) -
tests/test_tutorial/test_body_fields/test_tutorial001_an_py310.py
from dirty_equals import IsDict from fastapi.testclient import TestClient from ...utils import needs_py310 @pytest.fixture(name="client") def get_client(): from docs_src.body_fields.tutorial001_an_py310 import app client = TestClient(app) return client @needs_py310 def test_items_5(client: TestClient): response = client.put("/items/5", json={"item": {"name": "Foo", "price": 3.0}})
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Thu Apr 18 19:40:57 UTC 2024 - 7.3K bytes - Viewed (0) -
tests/test_tutorial/test_request_files/test_tutorial001_02_an.py
from fastapi.testclient import TestClient from docs_src.request_files.tutorial001_02_an import app client = TestClient(app) def test_post_form_no_body(): response = client.post("/files/") assert response.status_code == 200, response.text assert response.json() == {"message": "No file sent"} def test_post_uploadfile_no_body(): response = client.post("/uploadfile/") assert response.status_code == 200, response.text
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Jul 07 17:12:13 UTC 2023 - 8.2K bytes - Viewed (0) -
tests/test_tutorial/test_security/test_tutorial006.py
from docs_src.security.tutorial006 import app client = TestClient(app) def test_security_http_basic(): response = client.get("/users/me", auth=("john", "secret")) assert response.status_code == 200, response.text assert response.json() == {"username": "john", "password": "secret"} def test_security_http_basic_no_credentials(): response = client.get("/users/me")
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Jun 30 18:25:16 UTC 2023 - 2.3K bytes - Viewed (0) -
tests/test_tutorial/test_handling_errors/test_tutorial004.py
in response.text ) def test_get_http_error(): response = client.get("/items/3") assert response.status_code == 418, response.text assert response.content == b"Nope! I don't like 3." def test_get(): response = client.get("/items/2") assert response.status_code == 200, response.text assert response.json() == {"item_id": 2} def test_openapi_schema():
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Jul 07 17:12:13 UTC 2023 - 3.7K bytes - Viewed (0) -
tests/test_tutorial/test_query_params_str_validations/test_tutorial014_an.py
from docs_src.query_params_str_validations.tutorial014_an import app client = TestClient(app) def test_hidden_query(): response = client.get("/items?hidden_query=somevalue") assert response.status_code == 200, response.text assert response.json() == {"hidden_query": "somevalue"} def test_no_hidden_query(): response = client.get("/items") assert response.status_code == 200, response.text
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Jun 30 18:25:16 UTC 2023 - 2.9K bytes - Viewed (0) -
docs/zh/docs/advanced/events.md
# 事件:启动 - 关闭 **FastAPI** 支持定义在应用启动前,或应用关闭后执行的事件处理器(函数)。 事件函数既可以声明为异步函数(`async def`),也可以声明为普通函数(`def`)。 /// warning | "警告" **FastAPI** 只执行主应用中的事件处理器,不执行[子应用 - 挂载](sub-applications.md){.internal-link target=_blank}中的事件处理器。 /// ## `startup` 事件 使用 `startup` 事件声明 `app` 启动前运行的函数: ```Python hl_lines="8" {!../../docs_src/events/tutorial001.py!} ``` 本例中,`startup` 事件处理器函数为项目数据库(只是**字典**)提供了一些初始值。
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sun Oct 06 20:36:54 UTC 2024 - 1.7K bytes - Viewed (0) -
tests/test_tutorial/test_response_model/test_tutorial005_py310.py
from fastapi.testclient import TestClient from ...utils import needs_py310 @pytest.fixture(name="client") def get_client(): from docs_src.response_model.tutorial005_py310 import app client = TestClient(app) return client @needs_py310 def test_read_item_name(client: TestClient): response = client.get("/items/bar/name") assert response.status_code == 200, response.text
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Aug 04 20:47:07 UTC 2023 - 6.2K bytes - Viewed (0) -
tests/test_tutorial/test_request_files/test_tutorial001_03_an.py
client = TestClient(app) def test_post_file(tmp_path): path = tmp_path / "test.txt" path.write_bytes(b"<file content>") client = TestClient(app) with path.open("rb") as file: response = client.post("/files/", files={"file": file}) assert response.status_code == 200, response.text assert response.json() == {"file_size": 14} def test_post_upload_file(tmp_path):
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Jun 30 18:25:16 UTC 2023 - 6K bytes - Viewed (0)