test_tutorial003.py — fastapi Source File
Architecture documentation for test_tutorial003.py, a python file in the fastapi codebase. 4 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR da2d3095_b57b_ccf6_1a5b_348ba40f3b50["test_tutorial003.py"] 83e01a9c_50a9_bec9_6f86_8e729106de01["importlib"] da2d3095_b57b_ccf6_1a5b_348ba40f3b50 --> 83e01a9c_50a9_bec9_6f86_8e729106de01 fb2d9376_ca24_f2b2_f130_cc10e9f2e732["types"] da2d3095_b57b_ccf6_1a5b_348ba40f3b50 --> fb2d9376_ca24_f2b2_f130_cc10e9f2e732 5befe8bf_65d1_d058_6b78_4a597a8488e9["pytest"] da2d3095_b57b_ccf6_1a5b_348ba40f3b50 --> 5befe8bf_65d1_d058_6b78_4a597a8488e9 a7c04dee_ee23_5891_b185_47ff6bed036d["testclient.py"] da2d3095_b57b_ccf6_1a5b_348ba40f3b50 --> a7c04dee_ee23_5891_b185_47ff6bed036d style da2d3095_b57b_ccf6_1a5b_348ba40f3b50 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("tutorial003_py39"),
],
)
def get_mod(request: pytest.FixtureRequest):
mod = importlib.import_module(f"docs_src.websockets.{request.param}")
return mod
@pytest.fixture(name="html")
def get_html(mod: ModuleType):
return mod.html
@pytest.fixture(name="client")
def get_client(mod: ModuleType):
client = TestClient(mod.app)
return client
def test_get(client: TestClient, html: str):
response = client.get("/")
assert response.text == html
def test_websocket_handle_disconnection(client: TestClient):
with (
client.websocket_connect("/ws/1234") as connection,
client.websocket_connect("/ws/5678") as connection_two,
):
connection.send_text("Hello from 1234")
data1 = connection.receive_text()
assert data1 == "You wrote: Hello from 1234"
data2 = connection_two.receive_text()
client1_says = "Client #1234 says: Hello from 1234"
assert data2 == client1_says
data1 = connection.receive_text()
assert data1 == client1_says
connection_two.close()
data1 = connection.receive_text()
assert data1 == "Client #5678 left the chat"
Domain
Subdomains
Dependencies
- importlib
- pytest
- testclient.py
- types
Source
Frequently Asked Questions
What does test_tutorial003.py do?
test_tutorial003.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_tutorial003.py?
test_tutorial003.py defines 5 function(s): get_client, get_html, get_mod, test_get, test_websocket_handle_disconnection.
What does test_tutorial003.py depend on?
test_tutorial003.py imports 4 module(s): importlib, pytest, testclient.py, types.
Where is test_tutorial003.py in the architecture?
test_tutorial003.py is located at tests/test_tutorial/test_websockets/test_tutorial003.py (domain: FastAPI, subdomain: Responses, directory: tests/test_tutorial/test_websockets).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free