Skip to content
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
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ push = false
build = "cp*{manylinux,macosx}*"
enable = ["cpython-prerelease"]
test-extras = ["build", "test", "compat"]
test-command = "pytest -v --ignore={project}/tests/benchmarks --ignore={project}/tests/examples {project}/tests"
test-command = "pytest -v --ignore={project}/tests/benchmarks {project}/tests"

[tool.cibuildwheel.linux]
environment = { PYTEST_CODSPEED_FORCE_EXTENSION_BUILD = "1", PYTEST_CODSPEED_FORCE_VALGRIND_TESTS = "1" }
Expand Down Expand Up @@ -136,7 +136,7 @@ force_grid_wrap = 0
float_to_top = true

[tool.pytest.ini_options]
addopts = "--ignore=tests/benchmarks --ignore=tests/examples --ignore=tests/benchmarks/TheAlgorithms"
addopts = "--ignore=tests/benchmarks --ignore=tests/benchmarks/TheAlgorithms"
filterwarnings = ["ignore::DeprecationWarning:pytest_benchmark.utils.*:"]
pythonpath = ["tests/benchmarks/TheAlgorithms", "./scripts"]

Expand Down
7 changes: 7 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@
reason="pytest_xdist not installed",
)

ADDITION_BENCHMARK = """
def test_some_addition_performance(benchmark):
@benchmark
def _():
return 1 + 1
"""


@pytest.fixture(scope="function")
def codspeed_env(monkeypatch):
Expand Down
Empty file removed tests/examples/__init__.py
Empty file.
4 changes: 0 additions & 4 deletions tests/examples/test_addition_fixture.py

This file was deleted.

9 changes: 5 additions & 4 deletions tests/test_pytest_plugin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest
from conftest import (
ADDITION_BENCHMARK,
IS_PERF_TRAMPOLINE_SUPPORTED,
MeasurementMode,
run_pytest_codspeed_with_mode,
Expand Down Expand Up @@ -31,7 +32,7 @@ def fn(arg, kwarg=None):
def test_bench_enabled_header_without_perf(
pytester: pytest.Pytester, codspeed_env
) -> None:
pytester.copy_example("tests/examples/test_addition_fixture.py")
pytester.makepyfile(ADDITION_BENCHMARK)
with codspeed_env():
result = pytester.runpytest()
result.stdout.fnmatch_lines(
Expand All @@ -41,15 +42,15 @@ def test_bench_enabled_header_without_perf(

@skip_without_valgrind
def test_plugin_enabled_by_env(pytester: pytest.Pytester, codspeed_env) -> None:
pytester.copy_example("tests/examples/test_addition_fixture.py")
pytester.makepyfile(ADDITION_BENCHMARK)
with codspeed_env():
result = pytester.runpytest()
result.stdout.fnmatch_lines(["*1 benchmarked*", "*1 passed*"])


@skip_without_valgrind
def test_plugin_enabled_and_env(pytester: pytest.Pytester, codspeed_env) -> None:
pytester.copy_example("tests/examples/test_addition_fixture.py")
pytester.makepyfile(ADDITION_BENCHMARK)
with codspeed_env():
result = pytester.runpytest("--codspeed")
result.stdout.fnmatch_lines(["*1 benchmarked*", "*1 passed*"])
Expand Down Expand Up @@ -122,7 +123,7 @@ def test_child(self):

@xfail_pytest_benchmark_on_pytest_9_2
def test_plugin_disabled(pytester: pytest.Pytester) -> None:
pytester.copy_example("tests/examples/test_addition_fixture.py")
pytester.makepyfile(ADDITION_BENCHMARK)
result = pytester.runpytest()
result.stdout.fnmatch_lines(["*1 passed*"])

Expand Down
3 changes: 2 additions & 1 deletion tests/test_pytest_plugin_cpu_instrumentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import pytest
from conftest import (
ADDITION_BENCHMARK,
run_pytest_codspeed_with_mode,
skip_with_pytest_benchmark,
skip_without_perf_trampoline,
Expand All @@ -17,7 +18,7 @@
def test_bench_enabled_header_with_perf(
pytester: pytest.Pytester, codspeed_env
) -> None:
pytester.copy_example("tests/examples/test_addition_fixture.py")
pytester.makepyfile(ADDITION_BENCHMARK)
with codspeed_env():
result = pytester.runpytest()
result.stdout.fnmatch_lines(
Expand Down
4 changes: 2 additions & 2 deletions tests/test_pytest_plugin_walltime.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import TYPE_CHECKING

from conftest import run_pytest_codspeed_with_mode
from conftest import ADDITION_BENCHMARK, run_pytest_codspeed_with_mode

if TYPE_CHECKING:
import pytest
Expand All @@ -19,7 +19,7 @@
def test_bench_enabled_header_with_perf(
pytester: pytest.Pytester,
) -> None:
pytester.copy_example("tests/examples/test_addition_fixture.py")
pytester.makepyfile(ADDITION_BENCHMARK)
result = run_pytest_codspeed_with_mode(pytester, MeasurementMode.WallTime)
result.stdout.fnmatch_lines(["*test_some_addition_performance*", "*1 benchmarked*"])

Expand Down
Loading