test_tutorial008d.py — fastapi Source File
Architecture documentation for test_tutorial008d.py, a python file in the fastapi codebase. 4 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 08cbace0_5f9b_eb92_5f96_f21709993521["test_tutorial008d.py"] 83e01a9c_50a9_bec9_6f86_8e729106de01["importlib"] 08cbace0_5f9b_eb92_5f96_f21709993521 --> 83e01a9c_50a9_bec9_6f86_8e729106de01 fb2d9376_ca24_f2b2_f130_cc10e9f2e732["types"] 08cbace0_5f9b_eb92_5f96_f21709993521 --> fb2d9376_ca24_f2b2_f130_cc10e9f2e732 5befe8bf_65d1_d058_6b78_4a597a8488e9["pytest"] 08cbace0_5f9b_eb92_5f96_f21709993521 --> 5befe8bf_65d1_d058_6b78_4a597a8488e9 a7c04dee_ee23_5891_b185_47ff6bed036d["testclient.py"] 08cbace0_5f9b_eb92_5f96_f21709993521 --> a7c04dee_ee23_5891_b185_47ff6bed036d style 08cbace0_5f9b_eb92_5f96_f21709993521 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import importlib
from types import ModuleType
import pytest
from fastapi.testclient import TestClient
@pytest.fixture(
name="mod",
params=[
pytest.param("tutorial008d_py39"),
pytest.param("tutorial008d_an_py39"),
],
)
def get_mod(request: pytest.FixtureRequest):
mod = importlib.import_module(f"docs_src.dependencies.{request.param}")
return mod
def test_get_no_item(mod: ModuleType):
client = TestClient(mod.app)
response = client.get("/items/foo")
assert response.status_code == 404, response.text
assert response.json() == {"detail": "Item not found, there's only a plumbus here"}
def test_get(mod: ModuleType):
client = TestClient(mod.app)
response = client.get("/items/plumbus")
assert response.status_code == 200, response.text
assert response.json() == "plumbus"
def test_internal_error(mod: ModuleType):
client = TestClient(mod.app)
with pytest.raises(mod.InternalError) as exc_info:
client.get("/items/portal-gun")
assert (
exc_info.value.args[0] == "The portal gun is too dangerous to be owned by Rick"
)
def test_internal_server_error(mod: ModuleType):
client = TestClient(mod.app, raise_server_exceptions=False)
response = client.get("/items/portal-gun")
assert response.status_code == 500, response.text
assert response.text == "Internal Server Error"
Domain
Subdomains
Dependencies
- importlib
- pytest
- testclient.py
- types
Source
Frequently Asked Questions
What does test_tutorial008d.py do?
test_tutorial008d.py is a source file in the fastapi codebase, written in python. It belongs to the FastAPI domain, Responses subdomain.
What functions are defined in test_tutorial008d.py?
test_tutorial008d.py defines 5 function(s): get_mod, test_get, test_get_no_item, test_internal_error, test_internal_server_error.
What does test_tutorial008d.py depend on?
test_tutorial008d.py imports 4 module(s): importlib, pytest, testclient.py, types.
Where is test_tutorial008d.py in the architecture?
test_tutorial008d.py is located at tests/test_tutorial/test_dependencies/test_tutorial008d.py (domain: FastAPI, subdomain: Responses, directory: tests/test_tutorial/test_dependencies).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free