Browse Source

Skip only local file

pull/14558/head
Sebastián Ramírez 7 months ago
parent
commit
d1df363818
  1. 20
      tests/benchmarks/conftest.py
  2. 7
      tests/benchmarks/test_general_performance.py

20
tests/benchmarks/conftest.py

@ -1,20 +0,0 @@
import pytest
def pytest_collection_modifyitems(
config: pytest.Config, items: list[pytest.Item]
) -> None:
# Benchmarks are intentionally skipped unless explicitly requested with --codspeed
# to avoid slowing down regular test runs, and to run them only on
# supported Python versions (e.g. Pydantic v1 only up to Python 3.13).
run_codspeed = bool(getattr(config.option, "codspeed", False))
if run_codspeed:
return
skip_marker = pytest.mark.skip(
reason="Benchmark tests are skipped by default; run with --codspeed."
)
for item in items:
item.add_marker(skip_marker)

7
tests/benchmarks/test_general_performance.py

@ -1,4 +1,5 @@
import json
import sys
from collections.abc import Iterator
from typing import Annotated, Any
@ -7,6 +8,12 @@ from fastapi import Depends, FastAPI
from fastapi.testclient import TestClient
from pydantic import BaseModel, v1
if "--codspeed" not in sys.argv:
pytest.skip(
"Benchmark tests are skipped by default; run with --codspeed.",
allow_module_level=True,
)
LARGE_ITEMS: list[dict[str, Any]] = [
{
"id": i,

Loading…
Cancel
Save