From d1df36381850bd23df9c8dc655ebb21503c9dcb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Thu, 18 Dec 2025 13:31:15 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20Skip=20only=20local=20file?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/benchmarks/conftest.py | 20 -------------------- tests/benchmarks/test_general_performance.py | 7 +++++++ 2 files changed, 7 insertions(+), 20 deletions(-) delete mode 100644 tests/benchmarks/conftest.py diff --git a/tests/benchmarks/conftest.py b/tests/benchmarks/conftest.py deleted file mode 100644 index 082ae49b0..000000000 --- a/tests/benchmarks/conftest.py +++ /dev/null @@ -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) diff --git a/tests/benchmarks/test_general_performance.py b/tests/benchmarks/test_general_performance.py index e3bbacab3..af26df055 100644 --- a/tests/benchmarks/test_general_performance.py +++ b/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,