Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✅ Simplify tests for header_params #13179

Merged
merged 1 commit into from
Jan 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions tests/test_tutorial/test_header_params/test_tutorial001.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
import importlib

import pytest
from dirty_equals import IsDict
from fastapi.testclient import TestClient

from docs_src.header_params.tutorial001 import app
from ...utils import needs_py310


@pytest.fixture(
name="client",
params=[
"tutorial001",
pytest.param("tutorial001_py310", marks=needs_py310),
"tutorial001_an",
pytest.param("tutorial001_an_py310", marks=needs_py310),
],
)
def get_client(request: pytest.FixtureRequest):
mod = importlib.import_module(f"docs_src.header_params.{request.param}")

client = TestClient(app)
client = TestClient(mod.app)
return client


@pytest.mark.parametrize(
Expand All @@ -15,13 +31,13 @@
("/items", {"User-Agent": "FastAPI test"}, 200, {"User-Agent": "FastAPI test"}),
],
)
def test(path, headers, expected_status, expected_response):
def test(path, headers, expected_status, expected_response, client: TestClient):
response = client.get(path, headers=headers)
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
assert response.json() == {
Expand Down
102 changes: 0 additions & 102 deletions tests/test_tutorial/test_header_params/test_tutorial001_an.py

This file was deleted.

110 changes: 0 additions & 110 deletions tests/test_tutorial/test_header_params/test_tutorial001_an_py310.py

This file was deleted.

110 changes: 0 additions & 110 deletions tests/test_tutorial/test_header_params/test_tutorial001_py310.py

This file was deleted.

Loading
Loading