From 0de2e7c3e925c9d64a7ad17004e7e940217c641f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 24 Jun 2025 03:00:38 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20[pre-commit.ci]=20Auto=20format?= =?UTF-8?q?=20from=20pre-commit.com=20hooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_offline_docs/static/redoc.js | 2 +- tests/test_offline_docs/static/swagger.css | 2 +- tests/test_offline_docs/static/swagger.js | 2 +- .../test_root_path_with_static_mount.py | 54 +++++++++---------- 4 files changed, 27 insertions(+), 33 deletions(-) diff --git a/tests/test_offline_docs/static/redoc.js b/tests/test_offline_docs/static/redoc.js index f05278909..faba2abd5 100644 --- a/tests/test_offline_docs/static/redoc.js +++ b/tests/test_offline_docs/static/redoc.js @@ -1,3 +1,3 @@ function bar() { return "bar" -} \ No newline at end of file +} diff --git a/tests/test_offline_docs/static/swagger.css b/tests/test_offline_docs/static/swagger.css index 9f365baaa..310063de6 100644 --- a/tests/test_offline_docs/static/swagger.css +++ b/tests/test_offline_docs/static/swagger.css @@ -1 +1 @@ -.swagger-ui{color:#3b4151;} \ No newline at end of file +.swagger-ui{color:#3b4151;} diff --git a/tests/test_offline_docs/static/swagger.js b/tests/test_offline_docs/static/swagger.js index 7cc06f2f8..23c5b08a4 100644 --- a/tests/test_offline_docs/static/swagger.js +++ b/tests/test_offline_docs/static/swagger.js @@ -1,3 +1,3 @@ function foo() { return "foo" -} \ No newline at end of file +} diff --git a/tests/test_offline_docs/test_root_path_with_static_mount.py b/tests/test_offline_docs/test_root_path_with_static_mount.py index ebe203492..312ae771c 100644 --- a/tests/test_offline_docs/test_root_path_with_static_mount.py +++ b/tests/test_offline_docs/test_root_path_with_static_mount.py @@ -1,8 +1,7 @@ import pytest - from fastapi import FastAPI, Request +from fastapi.openapi.docs import get_redoc_html, get_swagger_ui_html from fastapi.staticfiles import StaticFiles -from fastapi.openapi.docs import get_swagger_ui_html, get_redoc_html from fastapi.testclient import TestClient @@ -13,7 +12,7 @@ from fastapi.testclient import TestClient ("/api", False), ("", True), ("", False), - ] + ], ) def test_swagger_docs_with_static_assets( root_path: str, @@ -22,27 +21,25 @@ def test_swagger_docs_with_static_assets( app_kwargs = {} client_kwargs = {} if not using_test_client: - app_kwargs = { - "root_path": root_path - } + app_kwargs = {"root_path": root_path} if using_test_client: - client_kwargs = { - "root_path": root_path - } - + client_kwargs = {"root_path": root_path} + app = FastAPI( title="FastAPI", docs_url=None, redoc_url=None, **app_kwargs, ) - - app.mount("/static", StaticFiles(directory="tests/test_offline_docs/static"), name="static") + + app.mount( + "/static", + StaticFiles(directory="tests/test_offline_docs/static"), + name="static", + ) @app.get("/") - async def custom_swagger_ui_html( - req: Request - ): + async def custom_swagger_ui_html(req: Request): """ Sets up a localized version of the Swagger (OpenAPI) docs that can be run without assets from the Internet. """ @@ -54,7 +51,6 @@ def test_swagger_docs_with_static_assets( swagger_css_url=f"{root_path}/static/swagger.css", ) - client = TestClient(app, **client_kwargs) response = client.get("/") @@ -85,7 +81,7 @@ def test_swagger_docs_with_static_assets( ("/api", False), ("", True), ("", False), - ] + ], ) def test_redoc_docs_with_static_assets( root_path: str, @@ -94,27 +90,25 @@ def test_redoc_docs_with_static_assets( app_kwargs = {} client_kwargs = {} if not using_test_client: - app_kwargs = { - "root_path": root_path - } + app_kwargs = {"root_path": root_path} if using_test_client: - client_kwargs = { - "root_path": root_path - } - + client_kwargs = {"root_path": root_path} + app = FastAPI( title="FastAPI", docs_url=None, redoc_url=None, **app_kwargs, ) - - app.mount("/static", StaticFiles(directory="tests/test_offline_docs/static"), name="static") + + app.mount( + "/static", + StaticFiles(directory="tests/test_offline_docs/static"), + name="static", + ) @app.get("/") - async def custom_redoc_html( - req: Request - ): + async def custom_redoc_html(req: Request): """ Sets up a localized version of the Swagger (OpenAPI) docs that can be run without assets from the Internet. """ @@ -141,4 +135,4 @@ def test_redoc_docs_with_static_assets( response = client.get(f"{root_path}/static/redoc.js") assert response.status_code == 200 - assert f"{root_path}/static/redoc.js" in redoc_html \ No newline at end of file + assert f"{root_path}/static/redoc.js" in redoc_html