1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
from unittest import mock
from textwrap import dedent
import pytest
from perf_tests.util import TimedSorter
pytest_plugins = ["pytester"]
@pytest.fixture
def fixture_path_relative(testdir):
for i_mod in range(10):
test_name = testdir.tmpdir.join(f"test_dep_perf{i_mod}.py")
test_contents = "import pytest\n"
for i in range(40):
test_contents += dedent(
f"""
@pytest.mark.dependency(depends=["test_{i + 50}"])
def test_{i}():
assert True
"""
)
for i in range(60):
test_contents += dedent(
f"""
@pytest.mark.dependency
def test_{i + 40}():
assert True
"""
)
test_name.write(test_contents)
yield testdir
@mock.patch("pytest_order.plugin.Sorter", TimedSorter)
def test_performance_dependency(fixture_path_relative):
"""Test performance of dependency markers that point to tests without
an order mark (same as for test_relative does for after markers)."""
TimedSorter.nr_marks = 400
fixture_path_relative.runpytest("--quiet", "--order-dependencies")
assert TimedSorter.elapsed < 0.15
|