Home / File/ test_empty_router.py — fastapi Source File

test_empty_router.py — fastapi Source File

Architecture documentation for test_empty_router.py, a python file in the fastapi codebase. 5 imports, 0 dependents.

File python FastAPI Routing 5 imports 3 functions

Entity Profile

Dependency Diagram

graph LR
  05ab92b4_4812_4a30_e766_7f42082c7523["test_empty_router.py"]
  5befe8bf_65d1_d058_6b78_4a597a8488e9["pytest"]
  05ab92b4_4812_4a30_e766_7f42082c7523 --> 5befe8bf_65d1_d058_6b78_4a597a8488e9
  534f6e44_61b8_3c38_8b89_6934a6df9802["__init__.py"]
  05ab92b4_4812_4a30_e766_7f42082c7523 --> 534f6e44_61b8_3c38_8b89_6934a6df9802
  01c652c5_d85c_f45e_848e_412c94ea4172["exceptions.py"]
  05ab92b4_4812_4a30_e766_7f42082c7523 --> 01c652c5_d85c_f45e_848e_412c94ea4172
  2d54c1ec_3e75_6f8e_face_5433598e4278["FastAPIError"]
  05ab92b4_4812_4a30_e766_7f42082c7523 --> 2d54c1ec_3e75_6f8e_face_5433598e4278
  a7c04dee_ee23_5891_b185_47ff6bed036d["testclient.py"]
  05ab92b4_4812_4a30_e766_7f42082c7523 --> a7c04dee_ee23_5891_b185_47ff6bed036d
  style 05ab92b4_4812_4a30_e766_7f42082c7523 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import pytest
from fastapi import APIRouter, FastAPI
from fastapi.exceptions import FastAPIError
from fastapi.testclient import TestClient

app = FastAPI()

router = APIRouter()


@router.get("")
def get_empty():
    return ["OK"]


app.include_router(router, prefix="/prefix")


client = TestClient(app)


def test_use_empty():
    with client:
        response = client.get("/prefix")
        assert response.status_code == 200, response.text
        assert response.json() == ["OK"]

        response = client.get("/prefix/")
        assert response.status_code == 200, response.text
        assert response.json() == ["OK"]


def test_include_empty():
    # if both include and router.path are empty - it should raise exception
    with pytest.raises(FastAPIError):
        app.include_router(router)

Domain

Subdomains

Frequently Asked Questions

What does test_empty_router.py do?
test_empty_router.py is a source file in the fastapi codebase, written in python. It belongs to the FastAPI domain, Routing subdomain.
What functions are defined in test_empty_router.py?
test_empty_router.py defines 3 function(s): get_empty, test_include_empty, test_use_empty.
What does test_empty_router.py depend on?
test_empty_router.py imports 5 module(s): FastAPIError, __init__.py, exceptions.py, pytest, testclient.py.
Where is test_empty_router.py in the architecture?
test_empty_router.py is located at tests/test_empty_router.py (domain: FastAPI, subdomain: Routing, directory: tests).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free