mirror of
https://github.com/fastapi/fastapi.git
synced 2026-06-16 19:40:45 -04:00
🔧 Add ty configs to check docs sources (#15770)
This commit is contained in:
committed by
GitHub
parent
4473a0cd91
commit
b7de2b7feb
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user