From 920df4d1ac3bba3ac14ac61ccd330d88975d7849 Mon Sep 17 00:00:00 2001
From: Alejandra <90076947+alejsdev@users.noreply.github.com>
Date: Sun, 19 Jan 2025 06:25:51 +0000
Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20Simplify=20tests=20for=20dependenci?=
 =?UTF-8?q?es=20(#13174)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../test_dependencies/test_tutorial001.py     |  25 +-
 .../test_dependencies/test_tutorial001_an.py  | 183 ------------
 .../test_tutorial001_an_py310.py              | 191 -------------
 .../test_tutorial001_an_py39.py               | 191 -------------
 .../test_tutorial001_py310.py                 | 191 -------------
 .../test_dependencies/test_tutorial004.py     |  25 +-
 .../test_dependencies/test_tutorial004_an.py  | 162 -----------
 .../test_tutorial004_an_py310.py              | 170 -----------
 .../test_tutorial004_an_py39.py               | 170 -----------
 .../test_tutorial004_py310.py                 | 170 -----------
 .../test_dependencies/test_tutorial006.py     |  30 +-
 .../test_dependencies/test_tutorial006_an.py  | 149 ----------
 .../test_tutorial006_an_py39.py               | 161 -----------
 .../test_dependencies/test_tutorial008b.py    |  26 +-
 .../test_dependencies/test_tutorial008b_an.py |  23 --
 .../test_tutorial008b_an_py39.py              |  33 ---
 .../test_dependencies/test_tutorial008c.py    |  36 ++-
 .../test_dependencies/test_tutorial008c_an.py |  38 ---
 .../test_tutorial008c_an_py39.py              |  44 ---
 .../test_dependencies/test_tutorial008d.py    |  40 ++-
 .../test_dependencies/test_tutorial008d_an.py |  41 ---
 .../test_tutorial008d_an_py39.py              |  47 ----
 .../test_dependencies/test_tutorial012.py     |  38 ++-
 .../test_dependencies/test_tutorial012_an.py  | 250 ----------------
 .../test_tutorial012_an_py39.py               | 266 ------------------
 25 files changed, 162 insertions(+), 2538 deletions(-)
 delete mode 100644 tests/test_tutorial/test_dependencies/test_tutorial001_an.py
 delete mode 100644 tests/test_tutorial/test_dependencies/test_tutorial001_an_py310.py
 delete mode 100644 tests/test_tutorial/test_dependencies/test_tutorial001_an_py39.py
 delete mode 100644 tests/test_tutorial/test_dependencies/test_tutorial001_py310.py
 delete mode 100644 tests/test_tutorial/test_dependencies/test_tutorial004_an.py
 delete mode 100644 tests/test_tutorial/test_dependencies/test_tutorial004_an_py310.py
 delete mode 100644 tests/test_tutorial/test_dependencies/test_tutorial004_an_py39.py
 delete mode 100644 tests/test_tutorial/test_dependencies/test_tutorial004_py310.py
 delete mode 100644 tests/test_tutorial/test_dependencies/test_tutorial006_an.py
 delete mode 100644 tests/test_tutorial/test_dependencies/test_tutorial006_an_py39.py
 delete mode 100644 tests/test_tutorial/test_dependencies/test_tutorial008b_an.py
 delete mode 100644 tests/test_tutorial/test_dependencies/test_tutorial008b_an_py39.py
 delete mode 100644 tests/test_tutorial/test_dependencies/test_tutorial008c_an.py
 delete mode 100644 tests/test_tutorial/test_dependencies/test_tutorial008c_an_py39.py
 delete mode 100644 tests/test_tutorial/test_dependencies/test_tutorial008d_an.py
 delete mode 100644 tests/test_tutorial/test_dependencies/test_tutorial008d_an_py39.py
 delete mode 100644 tests/test_tutorial/test_dependencies/test_tutorial012_an.py
 delete mode 100644 tests/test_tutorial/test_dependencies/test_tutorial012_an_py39.py

diff --git a/tests/test_tutorial/test_dependencies/test_tutorial001.py b/tests/test_tutorial/test_dependencies/test_tutorial001.py
index d1324a641..ed9944912 100644
--- a/tests/test_tutorial/test_dependencies/test_tutorial001.py
+++ b/tests/test_tutorial/test_dependencies/test_tutorial001.py
@@ -1,10 +1,27 @@
+import importlib
+
 import pytest
 from dirty_equals import IsDict
 from fastapi.testclient import TestClient
 
-from docs_src.dependencies.tutorial001 import app
+from ...utils import needs_py39, needs_py310
+
+
+@pytest.fixture(
+    name="client",
+    params=[
+        "tutorial001",
+        pytest.param("tutorial001_py310", marks=needs_py310),
+        "tutorial001_an",
+        pytest.param("tutorial001_an_py39", marks=needs_py39),
+        pytest.param("tutorial001_an_py310", marks=needs_py310),
+    ],
+)
+def get_client(request: pytest.FixtureRequest):
+    mod = importlib.import_module(f"docs_src.dependencies.{request.param}")
 
-client = TestClient(app)
+    client = TestClient(mod.app)
+    return client
 
 
 @pytest.mark.parametrize(
@@ -17,13 +34,13 @@ client = TestClient(app)
         ("/users", 200, {"q": None, "skip": 0, "limit": 100}),
     ],
 )
-def test_get(path, expected_status, expected_response):
+def test_get(path, expected_status, expected_response, client: TestClient):
     response = client.get(path)
     assert response.status_code == expected_status
     assert response.json() == expected_response
 
 
-def test_openapi_schema():
+def test_openapi_schema(client: TestClient):
     response = client.get("/openapi.json")
     assert response.status_code == 200, response.text
     assert response.json() == {
diff --git a/tests/test_tutorial/test_dependencies/test_tutorial001_an.py b/tests/test_tutorial/test_dependencies/test_tutorial001_an.py
deleted file mode 100644
index 79c2a1e10..000000000
--- a/tests/test_tutorial/test_dependencies/test_tutorial001_an.py
+++ /dev/null
@@ -1,183 +0,0 @@
-import pytest
-from dirty_equals import IsDict
-from fastapi.testclient import TestClient
-
-from docs_src.dependencies.tutorial001_an import app
-
-client = TestClient(app)
-
-
-@pytest.mark.parametrize(
-    "path,expected_status,expected_response",
-    [
-        ("/items", 200, {"q": None, "skip": 0, "limit": 100}),
-        ("/items?q=foo", 200, {"q": "foo", "skip": 0, "limit": 100}),
-        ("/items?q=foo&skip=5", 200, {"q": "foo", "skip": 5, "limit": 100}),
-        ("/items?q=foo&skip=5&limit=30", 200, {"q": "foo", "skip": 5, "limit": 30}),
-        ("/users", 200, {"q": None, "skip": 0, "limit": 100}),
-    ],
-)
-def test_get(path, expected_status, expected_response):
-    response = client.get(path)
-    assert response.status_code == expected_status
-    assert response.json() == expected_response
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == {
-        "openapi": "3.1.0",
-        "info": {"title": "FastAPI", "version": "0.1.0"},
-        "paths": {
-            "/items/": {
-                "get": {
-                    "responses": {
-                        "200": {
-                            "description": "Successful Response",
-                            "content": {"application/json": {"schema": {}}},
-                        },
-                        "422": {
-                            "description": "Validation Error",
-                            "content": {
-                                "application/json": {
-                                    "schema": {
-                                        "$ref": "#/components/schemas/HTTPValidationError"
-                                    }
-                                }
-                            },
-                        },
-                    },
-                    "summary": "Read Items",
-                    "operationId": "read_items_items__get",
-                    "parameters": [
-                        {
-                            "required": False,
-                            "schema": IsDict(
-                                {
-                                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                                    "title": "Q",
-                                }
-                            )
-                            | IsDict(
-                                # TODO: remove when deprecating Pydantic v1
-                                {"title": "Q", "type": "string"}
-                            ),
-                            "name": "q",
-                            "in": "query",
-                        },
-                        {
-                            "required": False,
-                            "schema": {
-                                "title": "Skip",
-                                "type": "integer",
-                                "default": 0,
-                            },
-                            "name": "skip",
-                            "in": "query",
-                        },
-                        {
-                            "required": False,
-                            "schema": {
-                                "title": "Limit",
-                                "type": "integer",
-                                "default": 100,
-                            },
-                            "name": "limit",
-                            "in": "query",
-                        },
-                    ],
-                }
-            },
-            "/users/": {
-                "get": {
-                    "responses": {
-                        "200": {
-                            "description": "Successful Response",
-                            "content": {"application/json": {"schema": {}}},
-                        },
-                        "422": {
-                            "description": "Validation Error",
-                            "content": {
-                                "application/json": {
-                                    "schema": {
-                                        "$ref": "#/components/schemas/HTTPValidationError"
-                                    }
-                                }
-                            },
-                        },
-                    },
-                    "summary": "Read Users",
-                    "operationId": "read_users_users__get",
-                    "parameters": [
-                        {
-                            "required": False,
-                            "schema": IsDict(
-                                {
-                                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                                    "title": "Q",
-                                }
-                            )
-                            | IsDict(
-                                # TODO: remove when deprecating Pydantic v1
-                                {"title": "Q", "type": "string"}
-                            ),
-                            "name": "q",
-                            "in": "query",
-                        },
-                        {
-                            "required": False,
-                            "schema": {
-                                "title": "Skip",
-                                "type": "integer",
-                                "default": 0,
-                            },
-                            "name": "skip",
-                            "in": "query",
-                        },
-                        {
-                            "required": False,
-                            "schema": {
-                                "title": "Limit",
-                                "type": "integer",
-                                "default": 100,
-                            },
-                            "name": "limit",
-                            "in": "query",
-                        },
-                    ],
-                }
-            },
-        },
-        "components": {
-            "schemas": {
-                "ValidationError": {
-                    "title": "ValidationError",
-                    "required": ["loc", "msg", "type"],
-                    "type": "object",
-                    "properties": {
-                        "loc": {
-                            "title": "Location",
-                            "type": "array",
-                            "items": {
-                                "anyOf": [{"type": "string"}, {"type": "integer"}]
-                            },
-                        },
-                        "msg": {"title": "Message", "type": "string"},
-                        "type": {"title": "Error Type", "type": "string"},
-                    },
-                },
-                "HTTPValidationError": {
-                    "title": "HTTPValidationError",
-                    "type": "object",
-                    "properties": {
-                        "detail": {
-                            "title": "Detail",
-                            "type": "array",
-                            "items": {"$ref": "#/components/schemas/ValidationError"},
-                        }
-                    },
-                },
-            }
-        },
-    }
diff --git a/tests/test_tutorial/test_dependencies/test_tutorial001_an_py310.py b/tests/test_tutorial/test_dependencies/test_tutorial001_an_py310.py
deleted file mode 100644
index 7db55a1c5..000000000
--- a/tests/test_tutorial/test_dependencies/test_tutorial001_an_py310.py
+++ /dev/null
@@ -1,191 +0,0 @@
-import pytest
-from dirty_equals import IsDict
-from fastapi.testclient import TestClient
-
-from ...utils import needs_py310
-
-
-@pytest.fixture(name="client")
-def get_client():
-    from docs_src.dependencies.tutorial001_an_py310 import app
-
-    client = TestClient(app)
-    return client
-
-
-@needs_py310
-@pytest.mark.parametrize(
-    "path,expected_status,expected_response",
-    [
-        ("/items", 200, {"q": None, "skip": 0, "limit": 100}),
-        ("/items?q=foo", 200, {"q": "foo", "skip": 0, "limit": 100}),
-        ("/items?q=foo&skip=5", 200, {"q": "foo", "skip": 5, "limit": 100}),
-        ("/items?q=foo&skip=5&limit=30", 200, {"q": "foo", "skip": 5, "limit": 30}),
-        ("/users", 200, {"q": None, "skip": 0, "limit": 100}),
-    ],
-)
-def test_get(path, expected_status, expected_response, client: TestClient):
-    response = client.get(path)
-    assert response.status_code == expected_status
-    assert response.json() == expected_response
-
-
-@needs_py310
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == {
-        "openapi": "3.1.0",
-        "info": {"title": "FastAPI", "version": "0.1.0"},
-        "paths": {
-            "/items/": {
-                "get": {
-                    "responses": {
-                        "200": {
-                            "description": "Successful Response",
-                            "content": {"application/json": {"schema": {}}},
-                        },
-                        "422": {
-                            "description": "Validation Error",
-                            "content": {
-                                "application/json": {
-                                    "schema": {
-                                        "$ref": "#/components/schemas/HTTPValidationError"
-                                    }
-                                }
-                            },
-                        },
-                    },
-                    "summary": "Read Items",
-                    "operationId": "read_items_items__get",
-                    "parameters": [
-                        {
-                            "required": False,
-                            "schema": IsDict(
-                                {
-                                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                                    "title": "Q",
-                                }
-                            )
-                            | IsDict(
-                                # TODO: remove when deprecating Pydantic v1
-                                {"title": "Q", "type": "string"}
-                            ),
-                            "name": "q",
-                            "in": "query",
-                        },
-                        {
-                            "required": False,
-                            "schema": {
-                                "title": "Skip",
-                                "type": "integer",
-                                "default": 0,
-                            },
-                            "name": "skip",
-                            "in": "query",
-                        },
-                        {
-                            "required": False,
-                            "schema": {
-                                "title": "Limit",
-                                "type": "integer",
-                                "default": 100,
-                            },
-                            "name": "limit",
-                            "in": "query",
-                        },
-                    ],
-                }
-            },
-            "/users/": {
-                "get": {
-                    "responses": {
-                        "200": {
-                            "description": "Successful Response",
-                            "content": {"application/json": {"schema": {}}},
-                        },
-                        "422": {
-                            "description": "Validation Error",
-                            "content": {
-                                "application/json": {
-                                    "schema": {
-                                        "$ref": "#/components/schemas/HTTPValidationError"
-                                    }
-                                }
-                            },
-                        },
-                    },
-                    "summary": "Read Users",
-                    "operationId": "read_users_users__get",
-                    "parameters": [
-                        {
-                            "required": False,
-                            "schema": IsDict(
-                                {
-                                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                                    "title": "Q",
-                                }
-                            )
-                            | IsDict(
-                                # TODO: remove when deprecating Pydantic v1
-                                {"title": "Q", "type": "string"}
-                            ),
-                            "name": "q",
-                            "in": "query",
-                        },
-                        {
-                            "required": False,
-                            "schema": {
-                                "title": "Skip",
-                                "type": "integer",
-                                "default": 0,
-                            },
-                            "name": "skip",
-                            "in": "query",
-                        },
-                        {
-                            "required": False,
-                            "schema": {
-                                "title": "Limit",
-                                "type": "integer",
-                                "default": 100,
-                            },
-                            "name": "limit",
-                            "in": "query",
-                        },
-                    ],
-                }
-            },
-        },
-        "components": {
-            "schemas": {
-                "ValidationError": {
-                    "title": "ValidationError",
-                    "required": ["loc", "msg", "type"],
-                    "type": "object",
-                    "properties": {
-                        "loc": {
-                            "title": "Location",
-                            "type": "array",
-                            "items": {
-                                "anyOf": [{"type": "string"}, {"type": "integer"}]
-                            },
-                        },
-                        "msg": {"title": "Message", "type": "string"},
-                        "type": {"title": "Error Type", "type": "string"},
-                    },
-                },
-                "HTTPValidationError": {
-                    "title": "HTTPValidationError",
-                    "type": "object",
-                    "properties": {
-                        "detail": {
-                            "title": "Detail",
-                            "type": "array",
-                            "items": {"$ref": "#/components/schemas/ValidationError"},
-                        }
-                    },
-                },
-            }
-        },
-    }
diff --git a/tests/test_tutorial/test_dependencies/test_tutorial001_an_py39.py b/tests/test_tutorial/test_dependencies/test_tutorial001_an_py39.py
deleted file mode 100644
index 68c2dedb1..000000000
--- a/tests/test_tutorial/test_dependencies/test_tutorial001_an_py39.py
+++ /dev/null
@@ -1,191 +0,0 @@
-import pytest
-from dirty_equals import IsDict
-from fastapi.testclient import TestClient
-
-from ...utils import needs_py39
-
-
-@pytest.fixture(name="client")
-def get_client():
-    from docs_src.dependencies.tutorial001_an_py39 import app
-
-    client = TestClient(app)
-    return client
-
-
-@needs_py39
-@pytest.mark.parametrize(
-    "path,expected_status,expected_response",
-    [
-        ("/items", 200, {"q": None, "skip": 0, "limit": 100}),
-        ("/items?q=foo", 200, {"q": "foo", "skip": 0, "limit": 100}),
-        ("/items?q=foo&skip=5", 200, {"q": "foo", "skip": 5, "limit": 100}),
-        ("/items?q=foo&skip=5&limit=30", 200, {"q": "foo", "skip": 5, "limit": 30}),
-        ("/users", 200, {"q": None, "skip": 0, "limit": 100}),
-    ],
-)
-def test_get(path, expected_status, expected_response, client: TestClient):
-    response = client.get(path)
-    assert response.status_code == expected_status
-    assert response.json() == expected_response
-
-
-@needs_py39
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == {
-        "openapi": "3.1.0",
-        "info": {"title": "FastAPI", "version": "0.1.0"},
-        "paths": {
-            "/items/": {
-                "get": {
-                    "responses": {
-                        "200": {
-                            "description": "Successful Response",
-                            "content": {"application/json": {"schema": {}}},
-                        },
-                        "422": {
-                            "description": "Validation Error",
-                            "content": {
-                                "application/json": {
-                                    "schema": {
-                                        "$ref": "#/components/schemas/HTTPValidationError"
-                                    }
-                                }
-                            },
-                        },
-                    },
-                    "summary": "Read Items",
-                    "operationId": "read_items_items__get",
-                    "parameters": [
-                        {
-                            "required": False,
-                            "schema": IsDict(
-                                {
-                                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                                    "title": "Q",
-                                }
-                            )
-                            | IsDict(
-                                # TODO: remove when deprecating Pydantic v1
-                                {"title": "Q", "type": "string"}
-                            ),
-                            "name": "q",
-                            "in": "query",
-                        },
-                        {
-                            "required": False,
-                            "schema": {
-                                "title": "Skip",
-                                "type": "integer",
-                                "default": 0,
-                            },
-                            "name": "skip",
-                            "in": "query",
-                        },
-                        {
-                            "required": False,
-                            "schema": {
-                                "title": "Limit",
-                                "type": "integer",
-                                "default": 100,
-                            },
-                            "name": "limit",
-                            "in": "query",
-                        },
-                    ],
-                }
-            },
-            "/users/": {
-                "get": {
-                    "responses": {
-                        "200": {
-                            "description": "Successful Response",
-                            "content": {"application/json": {"schema": {}}},
-                        },
-                        "422": {
-                            "description": "Validation Error",
-                            "content": {
-                                "application/json": {
-                                    "schema": {
-                                        "$ref": "#/components/schemas/HTTPValidationError"
-                                    }
-                                }
-                            },
-                        },
-                    },
-                    "summary": "Read Users",
-                    "operationId": "read_users_users__get",
-                    "parameters": [
-                        {
-                            "required": False,
-                            "schema": IsDict(
-                                {
-                                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                                    "title": "Q",
-                                }
-                            )
-                            | IsDict(
-                                # TODO: remove when deprecating Pydantic v1
-                                {"title": "Q", "type": "string"}
-                            ),
-                            "name": "q",
-                            "in": "query",
-                        },
-                        {
-                            "required": False,
-                            "schema": {
-                                "title": "Skip",
-                                "type": "integer",
-                                "default": 0,
-                            },
-                            "name": "skip",
-                            "in": "query",
-                        },
-                        {
-                            "required": False,
-                            "schema": {
-                                "title": "Limit",
-                                "type": "integer",
-                                "default": 100,
-                            },
-                            "name": "limit",
-                            "in": "query",
-                        },
-                    ],
-                }
-            },
-        },
-        "components": {
-            "schemas": {
-                "ValidationError": {
-                    "title": "ValidationError",
-                    "required": ["loc", "msg", "type"],
-                    "type": "object",
-                    "properties": {
-                        "loc": {
-                            "title": "Location",
-                            "type": "array",
-                            "items": {
-                                "anyOf": [{"type": "string"}, {"type": "integer"}]
-                            },
-                        },
-                        "msg": {"title": "Message", "type": "string"},
-                        "type": {"title": "Error Type", "type": "string"},
-                    },
-                },
-                "HTTPValidationError": {
-                    "title": "HTTPValidationError",
-                    "type": "object",
-                    "properties": {
-                        "detail": {
-                            "title": "Detail",
-                            "type": "array",
-                            "items": {"$ref": "#/components/schemas/ValidationError"},
-                        }
-                    },
-                },
-            }
-        },
-    }
diff --git a/tests/test_tutorial/test_dependencies/test_tutorial001_py310.py b/tests/test_tutorial/test_dependencies/test_tutorial001_py310.py
deleted file mode 100644
index 381eecb63..000000000
--- a/tests/test_tutorial/test_dependencies/test_tutorial001_py310.py
+++ /dev/null
@@ -1,191 +0,0 @@
-import pytest
-from dirty_equals import IsDict
-from fastapi.testclient import TestClient
-
-from ...utils import needs_py310
-
-
-@pytest.fixture(name="client")
-def get_client():
-    from docs_src.dependencies.tutorial001_py310 import app
-
-    client = TestClient(app)
-    return client
-
-
-@needs_py310
-@pytest.mark.parametrize(
-    "path,expected_status,expected_response",
-    [
-        ("/items", 200, {"q": None, "skip": 0, "limit": 100}),
-        ("/items?q=foo", 200, {"q": "foo", "skip": 0, "limit": 100}),
-        ("/items?q=foo&skip=5", 200, {"q": "foo", "skip": 5, "limit": 100}),
-        ("/items?q=foo&skip=5&limit=30", 200, {"q": "foo", "skip": 5, "limit": 30}),
-        ("/users", 200, {"q": None, "skip": 0, "limit": 100}),
-    ],
-)
-def test_get(path, expected_status, expected_response, client: TestClient):
-    response = client.get(path)
-    assert response.status_code == expected_status
-    assert response.json() == expected_response
-
-
-@needs_py310
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == {
-        "openapi": "3.1.0",
-        "info": {"title": "FastAPI", "version": "0.1.0"},
-        "paths": {
-            "/items/": {
-                "get": {
-                    "responses": {
-                        "200": {
-                            "description": "Successful Response",
-                            "content": {"application/json": {"schema": {}}},
-                        },
-                        "422": {
-                            "description": "Validation Error",
-                            "content": {
-                                "application/json": {
-                                    "schema": {
-                                        "$ref": "#/components/schemas/HTTPValidationError"
-                                    }
-                                }
-                            },
-                        },
-                    },
-                    "summary": "Read Items",
-                    "operationId": "read_items_items__get",
-                    "parameters": [
-                        {
-                            "required": False,
-                            "schema": IsDict(
-                                {
-                                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                                    "title": "Q",
-                                }
-                            )
-                            | IsDict(
-                                # TODO: remove when deprecating Pydantic v1
-                                {"title": "Q", "type": "string"}
-                            ),
-                            "name": "q",
-                            "in": "query",
-                        },
-                        {
-                            "required": False,
-                            "schema": {
-                                "title": "Skip",
-                                "type": "integer",
-                                "default": 0,
-                            },
-                            "name": "skip",
-                            "in": "query",
-                        },
-                        {
-                            "required": False,
-                            "schema": {
-                                "title": "Limit",
-                                "type": "integer",
-                                "default": 100,
-                            },
-                            "name": "limit",
-                            "in": "query",
-                        },
-                    ],
-                }
-            },
-            "/users/": {
-                "get": {
-                    "responses": {
-                        "200": {
-                            "description": "Successful Response",
-                            "content": {"application/json": {"schema": {}}},
-                        },
-                        "422": {
-                            "description": "Validation Error",
-                            "content": {
-                                "application/json": {
-                                    "schema": {
-                                        "$ref": "#/components/schemas/HTTPValidationError"
-                                    }
-                                }
-                            },
-                        },
-                    },
-                    "summary": "Read Users",
-                    "operationId": "read_users_users__get",
-                    "parameters": [
-                        {
-                            "required": False,
-                            "schema": IsDict(
-                                {
-                                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                                    "title": "Q",
-                                }
-                            )
-                            | IsDict(
-                                # TODO: remove when deprecating Pydantic v1
-                                {"title": "Q", "type": "string"}
-                            ),
-                            "name": "q",
-                            "in": "query",
-                        },
-                        {
-                            "required": False,
-                            "schema": {
-                                "title": "Skip",
-                                "type": "integer",
-                                "default": 0,
-                            },
-                            "name": "skip",
-                            "in": "query",
-                        },
-                        {
-                            "required": False,
-                            "schema": {
-                                "title": "Limit",
-                                "type": "integer",
-                                "default": 100,
-                            },
-                            "name": "limit",
-                            "in": "query",
-                        },
-                    ],
-                }
-            },
-        },
-        "components": {
-            "schemas": {
-                "ValidationError": {
-                    "title": "ValidationError",
-                    "required": ["loc", "msg", "type"],
-                    "type": "object",
-                    "properties": {
-                        "loc": {
-                            "title": "Location",
-                            "type": "array",
-                            "items": {
-                                "anyOf": [{"type": "string"}, {"type": "integer"}]
-                            },
-                        },
-                        "msg": {"title": "Message", "type": "string"},
-                        "type": {"title": "Error Type", "type": "string"},
-                    },
-                },
-                "HTTPValidationError": {
-                    "title": "HTTPValidationError",
-                    "type": "object",
-                    "properties": {
-                        "detail": {
-                            "title": "Detail",
-                            "type": "array",
-                            "items": {"$ref": "#/components/schemas/ValidationError"},
-                        }
-                    },
-                },
-            }
-        },
-    }
diff --git a/tests/test_tutorial/test_dependencies/test_tutorial004.py b/tests/test_tutorial/test_dependencies/test_tutorial004.py
index 5c5d34cfc..8221c83d4 100644
--- a/tests/test_tutorial/test_dependencies/test_tutorial004.py
+++ b/tests/test_tutorial/test_dependencies/test_tutorial004.py
@@ -1,10 +1,27 @@
+import importlib
+
 import pytest
 from dirty_equals import IsDict
 from fastapi.testclient import TestClient
 
-from docs_src.dependencies.tutorial004 import app
+from ...utils import needs_py39, needs_py310
+
+
+@pytest.fixture(
+    name="client",
+    params=[
+        "tutorial004",
+        pytest.param("tutorial004_py310", marks=needs_py310),
+        "tutorial004_an",
+        pytest.param("tutorial004_an_py39", marks=needs_py39),
+        pytest.param("tutorial004_an_py310", marks=needs_py310),
+    ],
+)
+def get_client(request: pytest.FixtureRequest):
+    mod = importlib.import_module(f"docs_src.dependencies.{request.param}")
 
-client = TestClient(app)
+    client = TestClient(mod.app)
+    return client
 
 
 @pytest.mark.parametrize(
@@ -55,13 +72,13 @@ client = TestClient(app)
         ),
     ],
 )
-def test_get(path, expected_status, expected_response):
+def test_get(path, expected_status, expected_response, client: TestClient):
     response = client.get(path)
     assert response.status_code == expected_status
     assert response.json() == expected_response
 
 
-def test_openapi_schema():
+def test_openapi_schema(client: TestClient):
     response = client.get("/openapi.json")
     assert response.status_code == 200, response.text
     assert response.json() == {
diff --git a/tests/test_tutorial/test_dependencies/test_tutorial004_an.py b/tests/test_tutorial/test_dependencies/test_tutorial004_an.py
deleted file mode 100644
index c5c1a1fb8..000000000
--- a/tests/test_tutorial/test_dependencies/test_tutorial004_an.py
+++ /dev/null
@@ -1,162 +0,0 @@
-import pytest
-from dirty_equals import IsDict
-from fastapi.testclient import TestClient
-
-from docs_src.dependencies.tutorial004_an import app
-
-client = TestClient(app)
-
-
-@pytest.mark.parametrize(
-    "path,expected_status,expected_response",
-    [
-        (
-            "/items",
-            200,
-            {
-                "items": [
-                    {"item_name": "Foo"},
-                    {"item_name": "Bar"},
-                    {"item_name": "Baz"},
-                ]
-            },
-        ),
-        (
-            "/items?q=foo",
-            200,
-            {
-                "items": [
-                    {"item_name": "Foo"},
-                    {"item_name": "Bar"},
-                    {"item_name": "Baz"},
-                ],
-                "q": "foo",
-            },
-        ),
-        (
-            "/items?q=foo&skip=1",
-            200,
-            {"items": [{"item_name": "Bar"}, {"item_name": "Baz"}], "q": "foo"},
-        ),
-        (
-            "/items?q=bar&limit=2",
-            200,
-            {"items": [{"item_name": "Foo"}, {"item_name": "Bar"}], "q": "bar"},
-        ),
-        (
-            "/items?q=bar&skip=1&limit=1",
-            200,
-            {"items": [{"item_name": "Bar"}], "q": "bar"},
-        ),
-        (
-            "/items?limit=1&q=bar&skip=1",
-            200,
-            {"items": [{"item_name": "Bar"}], "q": "bar"},
-        ),
-    ],
-)
-def test_get(path, expected_status, expected_response):
-    response = client.get(path)
-    assert response.status_code == expected_status
-    assert response.json() == expected_response
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == {
-        "openapi": "3.1.0",
-        "info": {"title": "FastAPI", "version": "0.1.0"},
-        "paths": {
-            "/items/": {
-                "get": {
-                    "responses": {
-                        "200": {
-                            "description": "Successful Response",
-                            "content": {"application/json": {"schema": {}}},
-                        },
-                        "422": {
-                            "description": "Validation Error",
-                            "content": {
-                                "application/json": {
-                                    "schema": {
-                                        "$ref": "#/components/schemas/HTTPValidationError"
-                                    }
-                                }
-                            },
-                        },
-                    },
-                    "summary": "Read Items",
-                    "operationId": "read_items_items__get",
-                    "parameters": [
-                        {
-                            "required": False,
-                            "schema": IsDict(
-                                {
-                                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                                    "title": "Q",
-                                }
-                            )
-                            | IsDict(
-                                # TODO: remove when deprecating Pydantic v1
-                                {"title": "Q", "type": "string"}
-                            ),
-                            "name": "q",
-                            "in": "query",
-                        },
-                        {
-                            "required": False,
-                            "schema": {
-                                "title": "Skip",
-                                "type": "integer",
-                                "default": 0,
-                            },
-                            "name": "skip",
-                            "in": "query",
-                        },
-                        {
-                            "required": False,
-                            "schema": {
-                                "title": "Limit",
-                                "type": "integer",
-                                "default": 100,
-                            },
-                            "name": "limit",
-                            "in": "query",
-                        },
-                    ],
-                }
-            }
-        },
-        "components": {
-            "schemas": {
-                "ValidationError": {
-                    "title": "ValidationError",
-                    "required": ["loc", "msg", "type"],
-                    "type": "object",
-                    "properties": {
-                        "loc": {
-                            "title": "Location",
-                            "type": "array",
-                            "items": {
-                                "anyOf": [{"type": "string"}, {"type": "integer"}]
-                            },
-                        },
-                        "msg": {"title": "Message", "type": "string"},
-                        "type": {"title": "Error Type", "type": "string"},
-                    },
-                },
-                "HTTPValidationError": {
-                    "title": "HTTPValidationError",
-                    "type": "object",
-                    "properties": {
-                        "detail": {
-                            "title": "Detail",
-                            "type": "array",
-                            "items": {"$ref": "#/components/schemas/ValidationError"},
-                        }
-                    },
-                },
-            }
-        },
-    }
diff --git a/tests/test_tutorial/test_dependencies/test_tutorial004_an_py310.py b/tests/test_tutorial/test_dependencies/test_tutorial004_an_py310.py
deleted file mode 100644
index 6fd093ddb..000000000
--- a/tests/test_tutorial/test_dependencies/test_tutorial004_an_py310.py
+++ /dev/null
@@ -1,170 +0,0 @@
-import pytest
-from dirty_equals import IsDict
-from fastapi.testclient import TestClient
-
-from ...utils import needs_py310
-
-
-@pytest.fixture(name="client")
-def get_client():
-    from docs_src.dependencies.tutorial004_an_py310 import app
-
-    client = TestClient(app)
-    return client
-
-
-@needs_py310
-@pytest.mark.parametrize(
-    "path,expected_status,expected_response",
-    [
-        (
-            "/items",
-            200,
-            {
-                "items": [
-                    {"item_name": "Foo"},
-                    {"item_name": "Bar"},
-                    {"item_name": "Baz"},
-                ]
-            },
-        ),
-        (
-            "/items?q=foo",
-            200,
-            {
-                "items": [
-                    {"item_name": "Foo"},
-                    {"item_name": "Bar"},
-                    {"item_name": "Baz"},
-                ],
-                "q": "foo",
-            },
-        ),
-        (
-            "/items?q=foo&skip=1",
-            200,
-            {"items": [{"item_name": "Bar"}, {"item_name": "Baz"}], "q": "foo"},
-        ),
-        (
-            "/items?q=bar&limit=2",
-            200,
-            {"items": [{"item_name": "Foo"}, {"item_name": "Bar"}], "q": "bar"},
-        ),
-        (
-            "/items?q=bar&skip=1&limit=1",
-            200,
-            {"items": [{"item_name": "Bar"}], "q": "bar"},
-        ),
-        (
-            "/items?limit=1&q=bar&skip=1",
-            200,
-            {"items": [{"item_name": "Bar"}], "q": "bar"},
-        ),
-    ],
-)
-def test_get(path, expected_status, expected_response, client: TestClient):
-    response = client.get(path)
-    assert response.status_code == expected_status
-    assert response.json() == expected_response
-
-
-@needs_py310
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == {
-        "openapi": "3.1.0",
-        "info": {"title": "FastAPI", "version": "0.1.0"},
-        "paths": {
-            "/items/": {
-                "get": {
-                    "responses": {
-                        "200": {
-                            "description": "Successful Response",
-                            "content": {"application/json": {"schema": {}}},
-                        },
-                        "422": {
-                            "description": "Validation Error",
-                            "content": {
-                                "application/json": {
-                                    "schema": {
-                                        "$ref": "#/components/schemas/HTTPValidationError"
-                                    }
-                                }
-                            },
-                        },
-                    },
-                    "summary": "Read Items",
-                    "operationId": "read_items_items__get",
-                    "parameters": [
-                        {
-                            "required": False,
-                            "schema": IsDict(
-                                {
-                                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                                    "title": "Q",
-                                }
-                            )
-                            | IsDict(
-                                # TODO: remove when deprecating Pydantic v1
-                                {"title": "Q", "type": "string"}
-                            ),
-                            "name": "q",
-                            "in": "query",
-                        },
-                        {
-                            "required": False,
-                            "schema": {
-                                "title": "Skip",
-                                "type": "integer",
-                                "default": 0,
-                            },
-                            "name": "skip",
-                            "in": "query",
-                        },
-                        {
-                            "required": False,
-                            "schema": {
-                                "title": "Limit",
-                                "type": "integer",
-                                "default": 100,
-                            },
-                            "name": "limit",
-                            "in": "query",
-                        },
-                    ],
-                }
-            }
-        },
-        "components": {
-            "schemas": {
-                "ValidationError": {
-                    "title": "ValidationError",
-                    "required": ["loc", "msg", "type"],
-                    "type": "object",
-                    "properties": {
-                        "loc": {
-                            "title": "Location",
-                            "type": "array",
-                            "items": {
-                                "anyOf": [{"type": "string"}, {"type": "integer"}]
-                            },
-                        },
-                        "msg": {"title": "Message", "type": "string"},
-                        "type": {"title": "Error Type", "type": "string"},
-                    },
-                },
-                "HTTPValidationError": {
-                    "title": "HTTPValidationError",
-                    "type": "object",
-                    "properties": {
-                        "detail": {
-                            "title": "Detail",
-                            "type": "array",
-                            "items": {"$ref": "#/components/schemas/ValidationError"},
-                        }
-                    },
-                },
-            }
-        },
-    }
diff --git a/tests/test_tutorial/test_dependencies/test_tutorial004_an_py39.py b/tests/test_tutorial/test_dependencies/test_tutorial004_an_py39.py
deleted file mode 100644
index fbbe84cc9..000000000
--- a/tests/test_tutorial/test_dependencies/test_tutorial004_an_py39.py
+++ /dev/null
@@ -1,170 +0,0 @@
-import pytest
-from dirty_equals import IsDict
-from fastapi.testclient import TestClient
-
-from ...utils import needs_py39
-
-
-@pytest.fixture(name="client")
-def get_client():
-    from docs_src.dependencies.tutorial004_an_py39 import app
-
-    client = TestClient(app)
-    return client
-
-
-@needs_py39
-@pytest.mark.parametrize(
-    "path,expected_status,expected_response",
-    [
-        (
-            "/items",
-            200,
-            {
-                "items": [
-                    {"item_name": "Foo"},
-                    {"item_name": "Bar"},
-                    {"item_name": "Baz"},
-                ]
-            },
-        ),
-        (
-            "/items?q=foo",
-            200,
-            {
-                "items": [
-                    {"item_name": "Foo"},
-                    {"item_name": "Bar"},
-                    {"item_name": "Baz"},
-                ],
-                "q": "foo",
-            },
-        ),
-        (
-            "/items?q=foo&skip=1",
-            200,
-            {"items": [{"item_name": "Bar"}, {"item_name": "Baz"}], "q": "foo"},
-        ),
-        (
-            "/items?q=bar&limit=2",
-            200,
-            {"items": [{"item_name": "Foo"}, {"item_name": "Bar"}], "q": "bar"},
-        ),
-        (
-            "/items?q=bar&skip=1&limit=1",
-            200,
-            {"items": [{"item_name": "Bar"}], "q": "bar"},
-        ),
-        (
-            "/items?limit=1&q=bar&skip=1",
-            200,
-            {"items": [{"item_name": "Bar"}], "q": "bar"},
-        ),
-    ],
-)
-def test_get(path, expected_status, expected_response, client: TestClient):
-    response = client.get(path)
-    assert response.status_code == expected_status
-    assert response.json() == expected_response
-
-
-@needs_py39
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == {
-        "openapi": "3.1.0",
-        "info": {"title": "FastAPI", "version": "0.1.0"},
-        "paths": {
-            "/items/": {
-                "get": {
-                    "responses": {
-                        "200": {
-                            "description": "Successful Response",
-                            "content": {"application/json": {"schema": {}}},
-                        },
-                        "422": {
-                            "description": "Validation Error",
-                            "content": {
-                                "application/json": {
-                                    "schema": {
-                                        "$ref": "#/components/schemas/HTTPValidationError"
-                                    }
-                                }
-                            },
-                        },
-                    },
-                    "summary": "Read Items",
-                    "operationId": "read_items_items__get",
-                    "parameters": [
-                        {
-                            "required": False,
-                            "schema": IsDict(
-                                {
-                                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                                    "title": "Q",
-                                }
-                            )
-                            | IsDict(
-                                # TODO: remove when deprecating Pydantic v1
-                                {"title": "Q", "type": "string"}
-                            ),
-                            "name": "q",
-                            "in": "query",
-                        },
-                        {
-                            "required": False,
-                            "schema": {
-                                "title": "Skip",
-                                "type": "integer",
-                                "default": 0,
-                            },
-                            "name": "skip",
-                            "in": "query",
-                        },
-                        {
-                            "required": False,
-                            "schema": {
-                                "title": "Limit",
-                                "type": "integer",
-                                "default": 100,
-                            },
-                            "name": "limit",
-                            "in": "query",
-                        },
-                    ],
-                }
-            }
-        },
-        "components": {
-            "schemas": {
-                "ValidationError": {
-                    "title": "ValidationError",
-                    "required": ["loc", "msg", "type"],
-                    "type": "object",
-                    "properties": {
-                        "loc": {
-                            "title": "Location",
-                            "type": "array",
-                            "items": {
-                                "anyOf": [{"type": "string"}, {"type": "integer"}]
-                            },
-                        },
-                        "msg": {"title": "Message", "type": "string"},
-                        "type": {"title": "Error Type", "type": "string"},
-                    },
-                },
-                "HTTPValidationError": {
-                    "title": "HTTPValidationError",
-                    "type": "object",
-                    "properties": {
-                        "detail": {
-                            "title": "Detail",
-                            "type": "array",
-                            "items": {"$ref": "#/components/schemas/ValidationError"},
-                        }
-                    },
-                },
-            }
-        },
-    }
diff --git a/tests/test_tutorial/test_dependencies/test_tutorial004_py310.py b/tests/test_tutorial/test_dependencies/test_tutorial004_py310.py
deleted file mode 100644
index 845b098e7..000000000
--- a/tests/test_tutorial/test_dependencies/test_tutorial004_py310.py
+++ /dev/null
@@ -1,170 +0,0 @@
-import pytest
-from dirty_equals import IsDict
-from fastapi.testclient import TestClient
-
-from ...utils import needs_py310
-
-
-@pytest.fixture(name="client")
-def get_client():
-    from docs_src.dependencies.tutorial004_py310 import app
-
-    client = TestClient(app)
-    return client
-
-
-@needs_py310
-@pytest.mark.parametrize(
-    "path,expected_status,expected_response",
-    [
-        (
-            "/items",
-            200,
-            {
-                "items": [
-                    {"item_name": "Foo"},
-                    {"item_name": "Bar"},
-                    {"item_name": "Baz"},
-                ]
-            },
-        ),
-        (
-            "/items?q=foo",
-            200,
-            {
-                "items": [
-                    {"item_name": "Foo"},
-                    {"item_name": "Bar"},
-                    {"item_name": "Baz"},
-                ],
-                "q": "foo",
-            },
-        ),
-        (
-            "/items?q=foo&skip=1",
-            200,
-            {"items": [{"item_name": "Bar"}, {"item_name": "Baz"}], "q": "foo"},
-        ),
-        (
-            "/items?q=bar&limit=2",
-            200,
-            {"items": [{"item_name": "Foo"}, {"item_name": "Bar"}], "q": "bar"},
-        ),
-        (
-            "/items?q=bar&skip=1&limit=1",
-            200,
-            {"items": [{"item_name": "Bar"}], "q": "bar"},
-        ),
-        (
-            "/items?limit=1&q=bar&skip=1",
-            200,
-            {"items": [{"item_name": "Bar"}], "q": "bar"},
-        ),
-    ],
-)
-def test_get(path, expected_status, expected_response, client: TestClient):
-    response = client.get(path)
-    assert response.status_code == expected_status
-    assert response.json() == expected_response
-
-
-@needs_py310
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == {
-        "openapi": "3.1.0",
-        "info": {"title": "FastAPI", "version": "0.1.0"},
-        "paths": {
-            "/items/": {
-                "get": {
-                    "responses": {
-                        "200": {
-                            "description": "Successful Response",
-                            "content": {"application/json": {"schema": {}}},
-                        },
-                        "422": {
-                            "description": "Validation Error",
-                            "content": {
-                                "application/json": {
-                                    "schema": {
-                                        "$ref": "#/components/schemas/HTTPValidationError"
-                                    }
-                                }
-                            },
-                        },
-                    },
-                    "summary": "Read Items",
-                    "operationId": "read_items_items__get",
-                    "parameters": [
-                        {
-                            "required": False,
-                            "schema": IsDict(
-                                {
-                                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                                    "title": "Q",
-                                }
-                            )
-                            | IsDict(
-                                # TODO: remove when deprecating Pydantic v1
-                                {"title": "Q", "type": "string"}
-                            ),
-                            "name": "q",
-                            "in": "query",
-                        },
-                        {
-                            "required": False,
-                            "schema": {
-                                "title": "Skip",
-                                "type": "integer",
-                                "default": 0,
-                            },
-                            "name": "skip",
-                            "in": "query",
-                        },
-                        {
-                            "required": False,
-                            "schema": {
-                                "title": "Limit",
-                                "type": "integer",
-                                "default": 100,
-                            },
-                            "name": "limit",
-                            "in": "query",
-                        },
-                    ],
-                }
-            }
-        },
-        "components": {
-            "schemas": {
-                "ValidationError": {
-                    "title": "ValidationError",
-                    "required": ["loc", "msg", "type"],
-                    "type": "object",
-                    "properties": {
-                        "loc": {
-                            "title": "Location",
-                            "type": "array",
-                            "items": {
-                                "anyOf": [{"type": "string"}, {"type": "integer"}]
-                            },
-                        },
-                        "msg": {"title": "Message", "type": "string"},
-                        "type": {"title": "Error Type", "type": "string"},
-                    },
-                },
-                "HTTPValidationError": {
-                    "title": "HTTPValidationError",
-                    "type": "object",
-                    "properties": {
-                        "detail": {
-                            "title": "Detail",
-                            "type": "array",
-                            "items": {"$ref": "#/components/schemas/ValidationError"},
-                        }
-                    },
-                },
-            }
-        },
-    }
diff --git a/tests/test_tutorial/test_dependencies/test_tutorial006.py b/tests/test_tutorial/test_dependencies/test_tutorial006.py
index 5f14d9a3b..4530762f7 100644
--- a/tests/test_tutorial/test_dependencies/test_tutorial006.py
+++ b/tests/test_tutorial/test_dependencies/test_tutorial006.py
@@ -1,12 +1,28 @@
+import importlib
+
+import pytest
 from dirty_equals import IsDict
 from fastapi.testclient import TestClient
 
-from docs_src.dependencies.tutorial006 import app
+from ...utils import needs_py39
+
+
+@pytest.fixture(
+    name="client",
+    params=[
+        "tutorial006",
+        "tutorial006_an",
+        pytest.param("tutorial006_an_py39", marks=needs_py39),
+    ],
+)
+def get_client(request: pytest.FixtureRequest):
+    mod = importlib.import_module(f"docs_src.dependencies.{request.param}")
 
-client = TestClient(app)
+    client = TestClient(mod.app)
+    return client
 
 
-def test_get_no_headers():
+def test_get_no_headers(client: TestClient):
     response = client.get("/items/")
     assert response.status_code == 422, response.text
     assert response.json() == IsDict(
@@ -45,13 +61,13 @@ def test_get_no_headers():
     )
 
 
-def test_get_invalid_one_header():
+def test_get_invalid_one_header(client: TestClient):
     response = client.get("/items/", headers={"X-Token": "invalid"})
     assert response.status_code == 400, response.text
     assert response.json() == {"detail": "X-Token header invalid"}
 
 
-def test_get_invalid_second_header():
+def test_get_invalid_second_header(client: TestClient):
     response = client.get(
         "/items/", headers={"X-Token": "fake-super-secret-token", "X-Key": "invalid"}
     )
@@ -59,7 +75,7 @@ def test_get_invalid_second_header():
     assert response.json() == {"detail": "X-Key header invalid"}
 
 
-def test_get_valid_headers():
+def test_get_valid_headers(client: TestClient):
     response = client.get(
         "/items/",
         headers={
@@ -71,7 +87,7 @@ def test_get_valid_headers():
     assert response.json() == [{"item": "Foo"}, {"item": "Bar"}]
 
 
-def test_openapi_schema():
+def test_openapi_schema(client: TestClient):
     response = client.get("/openapi.json")
     assert response.status_code == 200, response.text
     assert response.json() == {
diff --git a/tests/test_tutorial/test_dependencies/test_tutorial006_an.py b/tests/test_tutorial/test_dependencies/test_tutorial006_an.py
deleted file mode 100644
index a307ff808..000000000
--- a/tests/test_tutorial/test_dependencies/test_tutorial006_an.py
+++ /dev/null
@@ -1,149 +0,0 @@
-from dirty_equals import IsDict
-from fastapi.testclient import TestClient
-
-from docs_src.dependencies.tutorial006_an import app
-
-client = TestClient(app)
-
-
-def test_get_no_headers():
-    response = client.get("/items/")
-    assert response.status_code == 422, response.text
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["header", "x-token"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-                {
-                    "type": "missing",
-                    "loc": ["header", "x-key"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["header", "x-token"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-                {
-                    "loc": ["header", "x-key"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-            ]
-        }
-    )
-
-
-def test_get_invalid_one_header():
-    response = client.get("/items/", headers={"X-Token": "invalid"})
-    assert response.status_code == 400, response.text
-    assert response.json() == {"detail": "X-Token header invalid"}
-
-
-def test_get_invalid_second_header():
-    response = client.get(
-        "/items/", headers={"X-Token": "fake-super-secret-token", "X-Key": "invalid"}
-    )
-    assert response.status_code == 400, response.text
-    assert response.json() == {"detail": "X-Key header invalid"}
-
-
-def test_get_valid_headers():
-    response = client.get(
-        "/items/",
-        headers={
-            "X-Token": "fake-super-secret-token",
-            "X-Key": "fake-super-secret-key",
-        },
-    )
-    assert response.status_code == 200, response.text
-    assert response.json() == [{"item": "Foo"}, {"item": "Bar"}]
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == {
-        "openapi": "3.1.0",
-        "info": {"title": "FastAPI", "version": "0.1.0"},
-        "paths": {
-            "/items/": {
-                "get": {
-                    "responses": {
-                        "200": {
-                            "description": "Successful Response",
-                            "content": {"application/json": {"schema": {}}},
-                        },
-                        "422": {
-                            "description": "Validation Error",
-                            "content": {
-                                "application/json": {
-                                    "schema": {
-                                        "$ref": "#/components/schemas/HTTPValidationError"
-                                    }
-                                }
-                            },
-                        },
-                    },
-                    "summary": "Read Items",
-                    "operationId": "read_items_items__get",
-                    "parameters": [
-                        {
-                            "required": True,
-                            "schema": {"title": "X-Token", "type": "string"},
-                            "name": "x-token",
-                            "in": "header",
-                        },
-                        {
-                            "required": True,
-                            "schema": {"title": "X-Key", "type": "string"},
-                            "name": "x-key",
-                            "in": "header",
-                        },
-                    ],
-                }
-            }
-        },
-        "components": {
-            "schemas": {
-                "ValidationError": {
-                    "title": "ValidationError",
-                    "required": ["loc", "msg", "type"],
-                    "type": "object",
-                    "properties": {
-                        "loc": {
-                            "title": "Location",
-                            "type": "array",
-                            "items": {
-                                "anyOf": [{"type": "string"}, {"type": "integer"}]
-                            },
-                        },
-                        "msg": {"title": "Message", "type": "string"},
-                        "type": {"title": "Error Type", "type": "string"},
-                    },
-                },
-                "HTTPValidationError": {
-                    "title": "HTTPValidationError",
-                    "type": "object",
-                    "properties": {
-                        "detail": {
-                            "title": "Detail",
-                            "type": "array",
-                            "items": {"$ref": "#/components/schemas/ValidationError"},
-                        }
-                    },
-                },
-            }
-        },
-    }
diff --git a/tests/test_tutorial/test_dependencies/test_tutorial006_an_py39.py b/tests/test_tutorial/test_dependencies/test_tutorial006_an_py39.py
deleted file mode 100644
index b41b1537e..000000000
--- a/tests/test_tutorial/test_dependencies/test_tutorial006_an_py39.py
+++ /dev/null
@@ -1,161 +0,0 @@
-import pytest
-from dirty_equals import IsDict
-from fastapi.testclient import TestClient
-
-from ...utils import needs_py39
-
-
-@pytest.fixture(name="client")
-def get_client():
-    from docs_src.dependencies.tutorial006_an_py39 import app
-
-    client = TestClient(app)
-    return client
-
-
-@needs_py39
-def test_get_no_headers(client: TestClient):
-    response = client.get("/items/")
-    assert response.status_code == 422, response.text
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["header", "x-token"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-                {
-                    "type": "missing",
-                    "loc": ["header", "x-key"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["header", "x-token"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-                {
-                    "loc": ["header", "x-key"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-            ]
-        }
-    )
-
-
-@needs_py39
-def test_get_invalid_one_header(client: TestClient):
-    response = client.get("/items/", headers={"X-Token": "invalid"})
-    assert response.status_code == 400, response.text
-    assert response.json() == {"detail": "X-Token header invalid"}
-
-
-@needs_py39
-def test_get_invalid_second_header(client: TestClient):
-    response = client.get(
-        "/items/", headers={"X-Token": "fake-super-secret-token", "X-Key": "invalid"}
-    )
-    assert response.status_code == 400, response.text
-    assert response.json() == {"detail": "X-Key header invalid"}
-
-
-@needs_py39
-def test_get_valid_headers(client: TestClient):
-    response = client.get(
-        "/items/",
-        headers={
-            "X-Token": "fake-super-secret-token",
-            "X-Key": "fake-super-secret-key",
-        },
-    )
-    assert response.status_code == 200, response.text
-    assert response.json() == [{"item": "Foo"}, {"item": "Bar"}]
-
-
-@needs_py39
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == {
-        "openapi": "3.1.0",
-        "info": {"title": "FastAPI", "version": "0.1.0"},
-        "paths": {
-            "/items/": {
-                "get": {
-                    "responses": {
-                        "200": {
-                            "description": "Successful Response",
-                            "content": {"application/json": {"schema": {}}},
-                        },
-                        "422": {
-                            "description": "Validation Error",
-                            "content": {
-                                "application/json": {
-                                    "schema": {
-                                        "$ref": "#/components/schemas/HTTPValidationError"
-                                    }
-                                }
-                            },
-                        },
-                    },
-                    "summary": "Read Items",
-                    "operationId": "read_items_items__get",
-                    "parameters": [
-                        {
-                            "required": True,
-                            "schema": {"title": "X-Token", "type": "string"},
-                            "name": "x-token",
-                            "in": "header",
-                        },
-                        {
-                            "required": True,
-                            "schema": {"title": "X-Key", "type": "string"},
-                            "name": "x-key",
-                            "in": "header",
-                        },
-                    ],
-                }
-            }
-        },
-        "components": {
-            "schemas": {
-                "ValidationError": {
-                    "title": "ValidationError",
-                    "required": ["loc", "msg", "type"],
-                    "type": "object",
-                    "properties": {
-                        "loc": {
-                            "title": "Location",
-                            "type": "array",
-                            "items": {
-                                "anyOf": [{"type": "string"}, {"type": "integer"}]
-                            },
-                        },
-                        "msg": {"title": "Message", "type": "string"},
-                        "type": {"title": "Error Type", "type": "string"},
-                    },
-                },
-                "HTTPValidationError": {
-                    "title": "HTTPValidationError",
-                    "type": "object",
-                    "properties": {
-                        "detail": {
-                            "title": "Detail",
-                            "type": "array",
-                            "items": {"$ref": "#/components/schemas/ValidationError"},
-                        }
-                    },
-                },
-            }
-        },
-    }
diff --git a/tests/test_tutorial/test_dependencies/test_tutorial008b.py b/tests/test_tutorial/test_dependencies/test_tutorial008b.py
index 86acba9e4..4d7092265 100644
--- a/tests/test_tutorial/test_dependencies/test_tutorial008b.py
+++ b/tests/test_tutorial/test_dependencies/test_tutorial008b.py
@@ -1,23 +1,39 @@
+import importlib
+
+import pytest
 from fastapi.testclient import TestClient
 
-from docs_src.dependencies.tutorial008b import app
+from ...utils import needs_py39
+
+
+@pytest.fixture(
+    name="client",
+    params=[
+        "tutorial008b",
+        "tutorial008b_an",
+        pytest.param("tutorial008b_an_py39", marks=needs_py39),
+    ],
+)
+def get_client(request: pytest.FixtureRequest):
+    mod = importlib.import_module(f"docs_src.dependencies.{request.param}")
 
-client = TestClient(app)
+    client = TestClient(mod.app)
+    return client
 
 
-def test_get_no_item():
+def test_get_no_item(client: TestClient):
     response = client.get("/items/foo")
     assert response.status_code == 404, response.text
     assert response.json() == {"detail": "Item not found"}
 
 
-def test_owner_error():
+def test_owner_error(client: TestClient):
     response = client.get("/items/plumbus")
     assert response.status_code == 400, response.text
     assert response.json() == {"detail": "Owner error: Rick"}
 
 
-def test_get_item():
+def test_get_item(client: TestClient):
     response = client.get("/items/portal-gun")
     assert response.status_code == 200, response.text
     assert response.json() == {"description": "Gun to create portals", "owner": "Rick"}
diff --git a/tests/test_tutorial/test_dependencies/test_tutorial008b_an.py b/tests/test_tutorial/test_dependencies/test_tutorial008b_an.py
deleted file mode 100644
index 7f51fc52a..000000000
--- a/tests/test_tutorial/test_dependencies/test_tutorial008b_an.py
+++ /dev/null
@@ -1,23 +0,0 @@
-from fastapi.testclient import TestClient
-
-from docs_src.dependencies.tutorial008b_an import app
-
-client = TestClient(app)
-
-
-def test_get_no_item():
-    response = client.get("/items/foo")
-    assert response.status_code == 404, response.text
-    assert response.json() == {"detail": "Item not found"}
-
-
-def test_owner_error():
-    response = client.get("/items/plumbus")
-    assert response.status_code == 400, response.text
-    assert response.json() == {"detail": "Owner error: Rick"}
-
-
-def test_get_item():
-    response = client.get("/items/portal-gun")
-    assert response.status_code == 200, response.text
-    assert response.json() == {"description": "Gun to create portals", "owner": "Rick"}
diff --git a/tests/test_tutorial/test_dependencies/test_tutorial008b_an_py39.py b/tests/test_tutorial/test_dependencies/test_tutorial008b_an_py39.py
deleted file mode 100644
index 7d24809a8..000000000
--- a/tests/test_tutorial/test_dependencies/test_tutorial008b_an_py39.py
+++ /dev/null
@@ -1,33 +0,0 @@
-import pytest
-from fastapi.testclient import TestClient
-
-from ...utils import needs_py39
-
-
-@pytest.fixture(name="client")
-def get_client():
-    from docs_src.dependencies.tutorial008b_an_py39 import app
-
-    client = TestClient(app)
-    return client
-
-
-@needs_py39
-def test_get_no_item(client: TestClient):
-    response = client.get("/items/foo")
-    assert response.status_code == 404, response.text
-    assert response.json() == {"detail": "Item not found"}
-
-
-@needs_py39
-def test_owner_error(client: TestClient):
-    response = client.get("/items/plumbus")
-    assert response.status_code == 400, response.text
-    assert response.json() == {"detail": "Owner error: Rick"}
-
-
-@needs_py39
-def test_get_item(client: TestClient):
-    response = client.get("/items/portal-gun")
-    assert response.status_code == 200, response.text
-    assert response.json() == {"description": "Gun to create portals", "owner": "Rick"}
diff --git a/tests/test_tutorial/test_dependencies/test_tutorial008c.py b/tests/test_tutorial/test_dependencies/test_tutorial008c.py
index 27be8895a..11e96bf46 100644
--- a/tests/test_tutorial/test_dependencies/test_tutorial008c.py
+++ b/tests/test_tutorial/test_dependencies/test_tutorial008c.py
@@ -1,38 +1,50 @@
+import importlib
+from types import ModuleType
+
 import pytest
 from fastapi.exceptions import FastAPIError
 from fastapi.testclient import TestClient
 
+from ...utils import needs_py39
+
 
-@pytest.fixture(name="client")
-def get_client():
-    from docs_src.dependencies.tutorial008c import app
+@pytest.fixture(
+    name="mod",
+    params=[
+        "tutorial008c",
+        "tutorial008c_an",
+        pytest.param("tutorial008c_an_py39", marks=needs_py39),
+    ],
+)
+def get_mod(request: pytest.FixtureRequest):
+    mod = importlib.import_module(f"docs_src.dependencies.{request.param}")
 
-    client = TestClient(app)
-    return client
+    return mod
 
 
-def test_get_no_item(client: TestClient):
+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(client: TestClient):
+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_fastapi_error(client: TestClient):
+def test_fastapi_error(mod: ModuleType):
+    client = TestClient(mod.app)
     with pytest.raises(FastAPIError) as exc_info:
         client.get("/items/portal-gun")
     assert "No response object was returned" in exc_info.value.args[0]
 
 
-def test_internal_server_error():
-    from docs_src.dependencies.tutorial008c import app
-
-    client = TestClient(app, raise_server_exceptions=False)
+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"
diff --git a/tests/test_tutorial/test_dependencies/test_tutorial008c_an.py b/tests/test_tutorial/test_dependencies/test_tutorial008c_an.py
deleted file mode 100644
index 10fa1ab50..000000000
--- a/tests/test_tutorial/test_dependencies/test_tutorial008c_an.py
+++ /dev/null
@@ -1,38 +0,0 @@
-import pytest
-from fastapi.exceptions import FastAPIError
-from fastapi.testclient import TestClient
-
-
-@pytest.fixture(name="client")
-def get_client():
-    from docs_src.dependencies.tutorial008c_an import app
-
-    client = TestClient(app)
-    return client
-
-
-def test_get_no_item(client: TestClient):
-    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(client: TestClient):
-    response = client.get("/items/plumbus")
-    assert response.status_code == 200, response.text
-    assert response.json() == "plumbus"
-
-
-def test_fastapi_error(client: TestClient):
-    with pytest.raises(FastAPIError) as exc_info:
-        client.get("/items/portal-gun")
-    assert "No response object was returned" in exc_info.value.args[0]
-
-
-def test_internal_server_error():
-    from docs_src.dependencies.tutorial008c_an import app
-
-    client = TestClient(app, raise_server_exceptions=False)
-    response = client.get("/items/portal-gun")
-    assert response.status_code == 500, response.text
-    assert response.text == "Internal Server Error"
diff --git a/tests/test_tutorial/test_dependencies/test_tutorial008c_an_py39.py b/tests/test_tutorial/test_dependencies/test_tutorial008c_an_py39.py
deleted file mode 100644
index 6c3acff50..000000000
--- a/tests/test_tutorial/test_dependencies/test_tutorial008c_an_py39.py
+++ /dev/null
@@ -1,44 +0,0 @@
-import pytest
-from fastapi.exceptions import FastAPIError
-from fastapi.testclient import TestClient
-
-from ...utils import needs_py39
-
-
-@pytest.fixture(name="client")
-def get_client():
-    from docs_src.dependencies.tutorial008c_an_py39 import app
-
-    client = TestClient(app)
-    return client
-
-
-@needs_py39
-def test_get_no_item(client: TestClient):
-    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"}
-
-
-@needs_py39
-def test_get(client: TestClient):
-    response = client.get("/items/plumbus")
-    assert response.status_code == 200, response.text
-    assert response.json() == "plumbus"
-
-
-@needs_py39
-def test_fastapi_error(client: TestClient):
-    with pytest.raises(FastAPIError) as exc_info:
-        client.get("/items/portal-gun")
-    assert "No response object was returned" in exc_info.value.args[0]
-
-
-@needs_py39
-def test_internal_server_error():
-    from docs_src.dependencies.tutorial008c_an_py39 import app
-
-    client = TestClient(app, raise_server_exceptions=False)
-    response = client.get("/items/portal-gun")
-    assert response.status_code == 500, response.text
-    assert response.text == "Internal Server Error"
diff --git a/tests/test_tutorial/test_dependencies/test_tutorial008d.py b/tests/test_tutorial/test_dependencies/test_tutorial008d.py
index 043496112..bc99bb383 100644
--- a/tests/test_tutorial/test_dependencies/test_tutorial008d.py
+++ b/tests/test_tutorial/test_dependencies/test_tutorial008d.py
@@ -1,41 +1,51 @@
+import importlib
+from types import ModuleType
+
 import pytest
 from fastapi.testclient import TestClient
 
+from ...utils import needs_py39
+
 
-@pytest.fixture(name="client")
-def get_client():
-    from docs_src.dependencies.tutorial008d import app
+@pytest.fixture(
+    name="mod",
+    params=[
+        "tutorial008d",
+        "tutorial008d_an",
+        pytest.param("tutorial008d_an_py39", marks=needs_py39),
+    ],
+)
+def get_mod(request: pytest.FixtureRequest):
+    mod = importlib.import_module(f"docs_src.dependencies.{request.param}")
 
-    client = TestClient(app)
-    return client
+    return mod
 
 
-def test_get_no_item(client: TestClient):
+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(client: TestClient):
+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(client: TestClient):
-    from docs_src.dependencies.tutorial008d import InternalError
-
-    with pytest.raises(InternalError) as exc_info:
+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():
-    from docs_src.dependencies.tutorial008d import app
-
-    client = TestClient(app, raise_server_exceptions=False)
+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"
diff --git a/tests/test_tutorial/test_dependencies/test_tutorial008d_an.py b/tests/test_tutorial/test_dependencies/test_tutorial008d_an.py
deleted file mode 100644
index f29d8cdbe..000000000
--- a/tests/test_tutorial/test_dependencies/test_tutorial008d_an.py
+++ /dev/null
@@ -1,41 +0,0 @@
-import pytest
-from fastapi.testclient import TestClient
-
-
-@pytest.fixture(name="client")
-def get_client():
-    from docs_src.dependencies.tutorial008d_an import app
-
-    client = TestClient(app)
-    return client
-
-
-def test_get_no_item(client: TestClient):
-    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(client: TestClient):
-    response = client.get("/items/plumbus")
-    assert response.status_code == 200, response.text
-    assert response.json() == "plumbus"
-
-
-def test_internal_error(client: TestClient):
-    from docs_src.dependencies.tutorial008d_an import InternalError
-
-    with pytest.raises(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():
-    from docs_src.dependencies.tutorial008d_an import app
-
-    client = TestClient(app, raise_server_exceptions=False)
-    response = client.get("/items/portal-gun")
-    assert response.status_code == 500, response.text
-    assert response.text == "Internal Server Error"
diff --git a/tests/test_tutorial/test_dependencies/test_tutorial008d_an_py39.py b/tests/test_tutorial/test_dependencies/test_tutorial008d_an_py39.py
deleted file mode 100644
index 0a585f4ad..000000000
--- a/tests/test_tutorial/test_dependencies/test_tutorial008d_an_py39.py
+++ /dev/null
@@ -1,47 +0,0 @@
-import pytest
-from fastapi.testclient import TestClient
-
-from ...utils import needs_py39
-
-
-@pytest.fixture(name="client")
-def get_client():
-    from docs_src.dependencies.tutorial008d_an_py39 import app
-
-    client = TestClient(app)
-    return client
-
-
-@needs_py39
-def test_get_no_item(client: TestClient):
-    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"}
-
-
-@needs_py39
-def test_get(client: TestClient):
-    response = client.get("/items/plumbus")
-    assert response.status_code == 200, response.text
-    assert response.json() == "plumbus"
-
-
-@needs_py39
-def test_internal_error(client: TestClient):
-    from docs_src.dependencies.tutorial008d_an_py39 import InternalError
-
-    with pytest.raises(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"
-    )
-
-
-@needs_py39
-def test_internal_server_error():
-    from docs_src.dependencies.tutorial008d_an_py39 import app
-
-    client = TestClient(app, raise_server_exceptions=False)
-    response = client.get("/items/portal-gun")
-    assert response.status_code == 500, response.text
-    assert response.text == "Internal Server Error"
diff --git a/tests/test_tutorial/test_dependencies/test_tutorial012.py b/tests/test_tutorial/test_dependencies/test_tutorial012.py
index 6b53c83bb..0af17e9bc 100644
--- a/tests/test_tutorial/test_dependencies/test_tutorial012.py
+++ b/tests/test_tutorial/test_dependencies/test_tutorial012.py
@@ -1,12 +1,28 @@
+import importlib
+
+import pytest
 from dirty_equals import IsDict
 from fastapi.testclient import TestClient
 
-from docs_src.dependencies.tutorial012 import app
+from ...utils import needs_py39
+
+
+@pytest.fixture(
+    name="client",
+    params=[
+        "tutorial012",
+        "tutorial012_an",
+        pytest.param("tutorial012_an_py39", marks=needs_py39),
+    ],
+)
+def get_client(request: pytest.FixtureRequest):
+    mod = importlib.import_module(f"docs_src.dependencies.{request.param}")
 
-client = TestClient(app)
+    client = TestClient(mod.app)
+    return client
 
 
-def test_get_no_headers_items():
+def test_get_no_headers_items(client: TestClient):
     response = client.get("/items/")
     assert response.status_code == 422, response.text
     assert response.json() == IsDict(
@@ -45,7 +61,7 @@ def test_get_no_headers_items():
     )
 
 
-def test_get_no_headers_users():
+def test_get_no_headers_users(client: TestClient):
     response = client.get("/users/")
     assert response.status_code == 422, response.text
     assert response.json() == IsDict(
@@ -84,19 +100,19 @@ def test_get_no_headers_users():
     )
 
 
-def test_get_invalid_one_header_items():
+def test_get_invalid_one_header_items(client: TestClient):
     response = client.get("/items/", headers={"X-Token": "invalid"})
     assert response.status_code == 400, response.text
     assert response.json() == {"detail": "X-Token header invalid"}
 
 
-def test_get_invalid_one_users():
+def test_get_invalid_one_users(client: TestClient):
     response = client.get("/users/", headers={"X-Token": "invalid"})
     assert response.status_code == 400, response.text
     assert response.json() == {"detail": "X-Token header invalid"}
 
 
-def test_get_invalid_second_header_items():
+def test_get_invalid_second_header_items(client: TestClient):
     response = client.get(
         "/items/", headers={"X-Token": "fake-super-secret-token", "X-Key": "invalid"}
     )
@@ -104,7 +120,7 @@ def test_get_invalid_second_header_items():
     assert response.json() == {"detail": "X-Key header invalid"}
 
 
-def test_get_invalid_second_header_users():
+def test_get_invalid_second_header_users(client: TestClient):
     response = client.get(
         "/users/", headers={"X-Token": "fake-super-secret-token", "X-Key": "invalid"}
     )
@@ -112,7 +128,7 @@ def test_get_invalid_second_header_users():
     assert response.json() == {"detail": "X-Key header invalid"}
 
 
-def test_get_valid_headers_items():
+def test_get_valid_headers_items(client: TestClient):
     response = client.get(
         "/items/",
         headers={
@@ -124,7 +140,7 @@ def test_get_valid_headers_items():
     assert response.json() == [{"item": "Portal Gun"}, {"item": "Plumbus"}]
 
 
-def test_get_valid_headers_users():
+def test_get_valid_headers_users(client: TestClient):
     response = client.get(
         "/users/",
         headers={
@@ -136,7 +152,7 @@ def test_get_valid_headers_users():
     assert response.json() == [{"username": "Rick"}, {"username": "Morty"}]
 
 
-def test_openapi_schema():
+def test_openapi_schema(client: TestClient):
     response = client.get("/openapi.json")
     assert response.status_code == 200, response.text
     assert response.json() == {
diff --git a/tests/test_tutorial/test_dependencies/test_tutorial012_an.py b/tests/test_tutorial/test_dependencies/test_tutorial012_an.py
deleted file mode 100644
index 75adb69fc..000000000
--- a/tests/test_tutorial/test_dependencies/test_tutorial012_an.py
+++ /dev/null
@@ -1,250 +0,0 @@
-from dirty_equals import IsDict
-from fastapi.testclient import TestClient
-
-from docs_src.dependencies.tutorial012_an import app
-
-client = TestClient(app)
-
-
-def test_get_no_headers_items():
-    response = client.get("/items/")
-    assert response.status_code == 422, response.text
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["header", "x-token"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-                {
-                    "type": "missing",
-                    "loc": ["header", "x-key"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["header", "x-token"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-                {
-                    "loc": ["header", "x-key"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-            ]
-        }
-    )
-
-
-def test_get_no_headers_users():
-    response = client.get("/users/")
-    assert response.status_code == 422, response.text
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["header", "x-token"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-                {
-                    "type": "missing",
-                    "loc": ["header", "x-key"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["header", "x-token"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-                {
-                    "loc": ["header", "x-key"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-            ]
-        }
-    )
-
-
-def test_get_invalid_one_header_items():
-    response = client.get("/items/", headers={"X-Token": "invalid"})
-    assert response.status_code == 400, response.text
-    assert response.json() == {"detail": "X-Token header invalid"}
-
-
-def test_get_invalid_one_users():
-    response = client.get("/users/", headers={"X-Token": "invalid"})
-    assert response.status_code == 400, response.text
-    assert response.json() == {"detail": "X-Token header invalid"}
-
-
-def test_get_invalid_second_header_items():
-    response = client.get(
-        "/items/", headers={"X-Token": "fake-super-secret-token", "X-Key": "invalid"}
-    )
-    assert response.status_code == 400, response.text
-    assert response.json() == {"detail": "X-Key header invalid"}
-
-
-def test_get_invalid_second_header_users():
-    response = client.get(
-        "/users/", headers={"X-Token": "fake-super-secret-token", "X-Key": "invalid"}
-    )
-    assert response.status_code == 400, response.text
-    assert response.json() == {"detail": "X-Key header invalid"}
-
-
-def test_get_valid_headers_items():
-    response = client.get(
-        "/items/",
-        headers={
-            "X-Token": "fake-super-secret-token",
-            "X-Key": "fake-super-secret-key",
-        },
-    )
-    assert response.status_code == 200, response.text
-    assert response.json() == [{"item": "Portal Gun"}, {"item": "Plumbus"}]
-
-
-def test_get_valid_headers_users():
-    response = client.get(
-        "/users/",
-        headers={
-            "X-Token": "fake-super-secret-token",
-            "X-Key": "fake-super-secret-key",
-        },
-    )
-    assert response.status_code == 200, response.text
-    assert response.json() == [{"username": "Rick"}, {"username": "Morty"}]
-
-
-def test_openapi_schema():
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == {
-        "openapi": "3.1.0",
-        "info": {"title": "FastAPI", "version": "0.1.0"},
-        "paths": {
-            "/items/": {
-                "get": {
-                    "summary": "Read Items",
-                    "operationId": "read_items_items__get",
-                    "parameters": [
-                        {
-                            "required": True,
-                            "schema": {"title": "X-Token", "type": "string"},
-                            "name": "x-token",
-                            "in": "header",
-                        },
-                        {
-                            "required": True,
-                            "schema": {"title": "X-Key", "type": "string"},
-                            "name": "x-key",
-                            "in": "header",
-                        },
-                    ],
-                    "responses": {
-                        "200": {
-                            "description": "Successful Response",
-                            "content": {"application/json": {"schema": {}}},
-                        },
-                        "422": {
-                            "description": "Validation Error",
-                            "content": {
-                                "application/json": {
-                                    "schema": {
-                                        "$ref": "#/components/schemas/HTTPValidationError"
-                                    }
-                                }
-                            },
-                        },
-                    },
-                }
-            },
-            "/users/": {
-                "get": {
-                    "summary": "Read Users",
-                    "operationId": "read_users_users__get",
-                    "parameters": [
-                        {
-                            "required": True,
-                            "schema": {"title": "X-Token", "type": "string"},
-                            "name": "x-token",
-                            "in": "header",
-                        },
-                        {
-                            "required": True,
-                            "schema": {"title": "X-Key", "type": "string"},
-                            "name": "x-key",
-                            "in": "header",
-                        },
-                    ],
-                    "responses": {
-                        "200": {
-                            "description": "Successful Response",
-                            "content": {"application/json": {"schema": {}}},
-                        },
-                        "422": {
-                            "description": "Validation Error",
-                            "content": {
-                                "application/json": {
-                                    "schema": {
-                                        "$ref": "#/components/schemas/HTTPValidationError"
-                                    }
-                                }
-                            },
-                        },
-                    },
-                }
-            },
-        },
-        "components": {
-            "schemas": {
-                "HTTPValidationError": {
-                    "title": "HTTPValidationError",
-                    "type": "object",
-                    "properties": {
-                        "detail": {
-                            "title": "Detail",
-                            "type": "array",
-                            "items": {"$ref": "#/components/schemas/ValidationError"},
-                        }
-                    },
-                },
-                "ValidationError": {
-                    "title": "ValidationError",
-                    "required": ["loc", "msg", "type"],
-                    "type": "object",
-                    "properties": {
-                        "loc": {
-                            "title": "Location",
-                            "type": "array",
-                            "items": {
-                                "anyOf": [{"type": "string"}, {"type": "integer"}]
-                            },
-                        },
-                        "msg": {"title": "Message", "type": "string"},
-                        "type": {"title": "Error Type", "type": "string"},
-                    },
-                },
-            }
-        },
-    }
diff --git a/tests/test_tutorial/test_dependencies/test_tutorial012_an_py39.py b/tests/test_tutorial/test_dependencies/test_tutorial012_an_py39.py
deleted file mode 100644
index e0a3d1ec2..000000000
--- a/tests/test_tutorial/test_dependencies/test_tutorial012_an_py39.py
+++ /dev/null
@@ -1,266 +0,0 @@
-import pytest
-from dirty_equals import IsDict
-from fastapi.testclient import TestClient
-
-from ...utils import needs_py39
-
-
-@pytest.fixture(name="client")
-def get_client():
-    from docs_src.dependencies.tutorial012_an_py39 import app
-
-    client = TestClient(app)
-    return client
-
-
-@needs_py39
-def test_get_no_headers_items(client: TestClient):
-    response = client.get("/items/")
-    assert response.status_code == 422, response.text
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["header", "x-token"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-                {
-                    "type": "missing",
-                    "loc": ["header", "x-key"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["header", "x-token"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-                {
-                    "loc": ["header", "x-key"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-            ]
-        }
-    )
-
-
-@needs_py39
-def test_get_no_headers_users(client: TestClient):
-    response = client.get("/users/")
-    assert response.status_code == 422, response.text
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["header", "x-token"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-                {
-                    "type": "missing",
-                    "loc": ["header", "x-key"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["header", "x-token"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-                {
-                    "loc": ["header", "x-key"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-            ]
-        }
-    )
-
-
-@needs_py39
-def test_get_invalid_one_header_items(client: TestClient):
-    response = client.get("/items/", headers={"X-Token": "invalid"})
-    assert response.status_code == 400, response.text
-    assert response.json() == {"detail": "X-Token header invalid"}
-
-
-@needs_py39
-def test_get_invalid_one_users(client: TestClient):
-    response = client.get("/users/", headers={"X-Token": "invalid"})
-    assert response.status_code == 400, response.text
-    assert response.json() == {"detail": "X-Token header invalid"}
-
-
-@needs_py39
-def test_get_invalid_second_header_items(client: TestClient):
-    response = client.get(
-        "/items/", headers={"X-Token": "fake-super-secret-token", "X-Key": "invalid"}
-    )
-    assert response.status_code == 400, response.text
-    assert response.json() == {"detail": "X-Key header invalid"}
-
-
-@needs_py39
-def test_get_invalid_second_header_users(client: TestClient):
-    response = client.get(
-        "/users/", headers={"X-Token": "fake-super-secret-token", "X-Key": "invalid"}
-    )
-    assert response.status_code == 400, response.text
-    assert response.json() == {"detail": "X-Key header invalid"}
-
-
-@needs_py39
-def test_get_valid_headers_items(client: TestClient):
-    response = client.get(
-        "/items/",
-        headers={
-            "X-Token": "fake-super-secret-token",
-            "X-Key": "fake-super-secret-key",
-        },
-    )
-    assert response.status_code == 200, response.text
-    assert response.json() == [{"item": "Portal Gun"}, {"item": "Plumbus"}]
-
-
-@needs_py39
-def test_get_valid_headers_users(client: TestClient):
-    response = client.get(
-        "/users/",
-        headers={
-            "X-Token": "fake-super-secret-token",
-            "X-Key": "fake-super-secret-key",
-        },
-    )
-    assert response.status_code == 200, response.text
-    assert response.json() == [{"username": "Rick"}, {"username": "Morty"}]
-
-
-@needs_py39
-def test_openapi_schema(client: TestClient):
-    response = client.get("/openapi.json")
-    assert response.status_code == 200, response.text
-    assert response.json() == {
-        "openapi": "3.1.0",
-        "info": {"title": "FastAPI", "version": "0.1.0"},
-        "paths": {
-            "/items/": {
-                "get": {
-                    "summary": "Read Items",
-                    "operationId": "read_items_items__get",
-                    "parameters": [
-                        {
-                            "required": True,
-                            "schema": {"title": "X-Token", "type": "string"},
-                            "name": "x-token",
-                            "in": "header",
-                        },
-                        {
-                            "required": True,
-                            "schema": {"title": "X-Key", "type": "string"},
-                            "name": "x-key",
-                            "in": "header",
-                        },
-                    ],
-                    "responses": {
-                        "200": {
-                            "description": "Successful Response",
-                            "content": {"application/json": {"schema": {}}},
-                        },
-                        "422": {
-                            "description": "Validation Error",
-                            "content": {
-                                "application/json": {
-                                    "schema": {
-                                        "$ref": "#/components/schemas/HTTPValidationError"
-                                    }
-                                }
-                            },
-                        },
-                    },
-                }
-            },
-            "/users/": {
-                "get": {
-                    "summary": "Read Users",
-                    "operationId": "read_users_users__get",
-                    "parameters": [
-                        {
-                            "required": True,
-                            "schema": {"title": "X-Token", "type": "string"},
-                            "name": "x-token",
-                            "in": "header",
-                        },
-                        {
-                            "required": True,
-                            "schema": {"title": "X-Key", "type": "string"},
-                            "name": "x-key",
-                            "in": "header",
-                        },
-                    ],
-                    "responses": {
-                        "200": {
-                            "description": "Successful Response",
-                            "content": {"application/json": {"schema": {}}},
-                        },
-                        "422": {
-                            "description": "Validation Error",
-                            "content": {
-                                "application/json": {
-                                    "schema": {
-                                        "$ref": "#/components/schemas/HTTPValidationError"
-                                    }
-                                }
-                            },
-                        },
-                    },
-                }
-            },
-        },
-        "components": {
-            "schemas": {
-                "HTTPValidationError": {
-                    "title": "HTTPValidationError",
-                    "type": "object",
-                    "properties": {
-                        "detail": {
-                            "title": "Detail",
-                            "type": "array",
-                            "items": {"$ref": "#/components/schemas/ValidationError"},
-                        }
-                    },
-                },
-                "ValidationError": {
-                    "title": "ValidationError",
-                    "required": ["loc", "msg", "type"],
-                    "type": "object",
-                    "properties": {
-                        "loc": {
-                            "title": "Location",
-                            "type": "array",
-                            "items": {
-                                "anyOf": [{"type": "string"}, {"type": "integer"}]
-                            },
-                        },
-                        "msg": {"title": "Message", "type": "string"},
-                        "type": {"title": "Error Type", "type": "string"},
-                    },
-                },
-            }
-        },
-    }