summaryrefslogtreecommitdiffstats
path: root/tests/benchmark/test_runner.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/benchmark/test_runner.py')
-rw-r--r--tests/benchmark/test_runner.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/tests/benchmark/test_runner.py b/tests/benchmark/test_runner.py
index b020a85..a8639af 100644
--- a/tests/benchmark/test_runner.py
+++ b/tests/benchmark/test_runner.py
@@ -5,19 +5,21 @@
from __future__ import annotations
-from typing import TYPE_CHECKING
+from typing import TYPE_CHECKING, Any
from anta.result_manager import ResultManager
from anta.runner import get_coroutines, prepare_tests
if TYPE_CHECKING:
from collections import defaultdict
+ from collections.abc import Coroutine
from pytest_codspeed import BenchmarkFixture
from anta.catalog import AntaCatalog, AntaTestDefinition
from anta.device import AntaDevice
from anta.inventory import AntaInventory
+ from anta.result_manager.models import TestResult
def test_prepare_tests(benchmark: BenchmarkFixture, catalog: AntaCatalog, inventory: AntaInventory) -> None:
@@ -40,9 +42,13 @@ def test_get_coroutines(benchmark: BenchmarkFixture, catalog: AntaCatalog, inven
assert selected_tests is not None
- coroutines = benchmark(lambda: get_coroutines(selected_tests=selected_tests, manager=ResultManager()))
- for coros in coroutines:
- coros.close()
+ def bench() -> list[Coroutine[Any, Any, TestResult]]:
+ coros = get_coroutines(selected_tests=selected_tests, manager=ResultManager())
+ for c in coros:
+ c.close()
+ return coros
+
+ coroutines = benchmark(bench)
count = sum(len(tests) for tests in selected_tests.values())
assert count == len(coroutines)