Home / Function/ test_main() — fastapi Function Reference

test_main() — fastapi Function Reference

Architecture documentation for the test_main() function in test_tutorial001.py from the fastapi codebase.

Entity Profile

Dependency Diagram

graph TD
  a2e9fb4c_501b_faed_4f75_c210a92b9d51["test_main()"]
  2355bfdc_648a_591d_bfb5_a167c787264d["test_tutorial001.py"]
  a2e9fb4c_501b_faed_4f75_c210a92b9d51 -->|defined in| 2355bfdc_648a_591d_bfb5_a167c787264d
  style a2e9fb4c_501b_faed_4f75_c210a92b9d51 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/test_tutorial/test_templates/test_tutorial001.py lines 7–27

def test_main():
    if os.path.isdir("./static"):  # pragma: nocover
        shutil.rmtree("./static")
    if os.path.isdir("./templates"):  # pragma: nocover
        shutil.rmtree("./templates")
    shutil.copytree("./docs_src/templates/templates/", "./templates")
    shutil.copytree("./docs_src/templates/static/", "./static")
    from docs_src.templates.tutorial001_py39 import app

    client = TestClient(app)
    response = client.get("/items/foo")
    assert response.status_code == 200, response.text
    assert (
        b'<h1><a href="http://testserver/items/foo">Item ID: foo</a></h1>'
        in response.content
    )
    response = client.get("/static/styles.css")
    assert response.status_code == 200, response.text
    assert b"color: green;" in response.content
    shutil.rmtree("./templates")
    shutil.rmtree("./static")

Domain

Subdomains

Frequently Asked Questions

What does test_main() do?
test_main() is a function in the fastapi codebase, defined in tests/test_tutorial/test_templates/test_tutorial001.py.
Where is test_main() defined?
test_main() is defined in tests/test_tutorial/test_templates/test_tutorial001.py at line 7.

Analyze Your Own Codebase

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

Try Supermodel Free