🔧 Add ty configs to check docs sources (#15770)

This commit is contained in:
Sebastián Ramírez
2026-06-15 17:53:46 +02:00
committed by GitHub
parent 4473a0cd91
commit b7de2b7feb
44 changed files with 149 additions and 118 deletions

View File

@@ -1,7 +1,7 @@
import importlib
import runpy
import sys
import unittest
from unittest import mock
import pytest
from fastapi.testclient import TestClient
@@ -20,7 +20,7 @@ def get_client():
def test_uvicorn_run_is_not_called_on_import():
if sys.modules.get(MOD_NAME):
del sys.modules[MOD_NAME] # pragma: no cover
with unittest.mock.patch("uvicorn.run") as uvicorn_run_mock:
with mock.patch("uvicorn.run") as uvicorn_run_mock:
importlib.import_module(MOD_NAME)
uvicorn_run_mock.assert_not_called()
@@ -34,12 +34,10 @@ def test_get_root(client: TestClient):
def test_uvicorn_run_called_when_run_as_main(): # Just for coverage
if sys.modules.get(MOD_NAME):
del sys.modules[MOD_NAME]
with unittest.mock.patch("uvicorn.run") as uvicorn_run_mock:
with mock.patch("uvicorn.run") as uvicorn_run_mock:
runpy.run_module(MOD_NAME, run_name="__main__")
uvicorn_run_mock.assert_called_once_with(
unittest.mock.ANY, host="0.0.0.0", port=8000
)
uvicorn_run_mock.assert_called_once_with(mock.ANY, host="0.0.0.0", port=8000)
def test_openapi_schema(client: TestClient):