From c75bc9b8b001737b0f5072099791cc6f0012f605 Mon Sep 17 00:00:00 2001 From: Dmitry Rodionov Date: Thu, 4 Nov 2021 13:02:09 +0300 Subject: [PATCH] Change benchmark plugin layout so pytest loads it properly when running all tests (not necessary performance ones) resolves #837 --- test_runner/conftest.py | 2 +- test_runner/fixtures/benchmark_fixture.py | 10 +++++++++- test_runner/fixtures/zenith_fixtures.py | 3 +-- test_runner/performance/conftest.py | 8 -------- 4 files changed, 11 insertions(+), 12 deletions(-) delete mode 100644 test_runner/performance/conftest.py diff --git a/test_runner/conftest.py b/test_runner/conftest.py index 998034bd21..09a7a7236c 100644 --- a/test_runner/conftest.py +++ b/test_runner/conftest.py @@ -1 +1 @@ -pytest_plugins = ("fixtures.zenith_fixtures") +pytest_plugins = ("fixtures.zenith_fixtures", "fixtures.benchmark_fixture") diff --git a/test_runner/fixtures/benchmark_fixture.py b/test_runner/fixtures/benchmark_fixture.py index a83cbc95dd..579694ab37 100644 --- a/test_runner/fixtures/benchmark_fixture.py +++ b/test_runner/fixtures/benchmark_fixture.py @@ -16,7 +16,7 @@ import warnings from contextlib import contextmanager # Type-related stuff -from typing import Iterator, Optional +from typing import Iterator """ This file contains fixtures for micro-benchmarks. @@ -314,6 +314,14 @@ def zenbenchmark(record_property) -> Iterator[ZenithBenchmarker]: yield benchmarker +def pytest_addoption(parser): + parser.addoption( + "--out-dir", + dest="out_dir", + help="Directory to ouput performance tests results to.", + ) + + def get_out_path(target_dir: Path, revision: str) -> Path: """ get output file path diff --git a/test_runner/fixtures/zenith_fixtures.py b/test_runner/fixtures/zenith_fixtures.py index 48faf47a6d..0a32c5bffb 100644 --- a/test_runner/fixtures/zenith_fixtures.py +++ b/test_runner/fixtures/zenith_fixtures.py @@ -12,14 +12,13 @@ import json import psycopg2 import pytest import shutil -import signal import socket import subprocess import time import filecmp import tempfile -from contextlib import closing, suppress +from contextlib import closing from pathlib import Path from dataclasses import dataclass diff --git a/test_runner/performance/conftest.py b/test_runner/performance/conftest.py deleted file mode 100644 index cd8b40ca82..0000000000 --- a/test_runner/performance/conftest.py +++ /dev/null @@ -1,8 +0,0 @@ -# pytest some has quirks with discovering plugins, so having it there just works -# probably we should create custom plugin and add it to pytest config to always have needed things at hand -def pytest_addoption(parser): - parser.addoption( - "--out-dir", - dest="out_dir", - help="Directory to ouput performance tests results to.", - )