aboutsummaryrefslogtreecommitdiffstats
path: root/library/python/pytest/plugins/fixtures.py
diff options
context:
space:
mode:
authorDmitry Kopylov <kopylovd@gmail.com>2022-02-10 16:48:18 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:48:18 +0300
commit7230275728d34873cba1ba78bb68669b0c5faa31 (patch)
treeb222e5ac2e2e98872661c51ccceee5da0d291e13 /library/python/pytest/plugins/fixtures.py
parentb2f5101486cc0de2e979c8ba9ada2109785bf5fd (diff)
downloadydb-7230275728d34873cba1ba78bb68669b0c5faa31.tar.gz
Restoring authorship annotation for Dmitry Kopylov <kopylovd@gmail.com>. Commit 2 of 2.
Diffstat (limited to 'library/python/pytest/plugins/fixtures.py')
-rw-r--r--library/python/pytest/plugins/fixtures.py120
1 files changed, 60 insertions, 60 deletions
diff --git a/library/python/pytest/plugins/fixtures.py b/library/python/pytest/plugins/fixtures.py
index 9f5fd6ccf1..6f7e0a27e4 100644
--- a/library/python/pytest/plugins/fixtures.py
+++ b/library/python/pytest/plugins/fixtures.py
@@ -1,26 +1,26 @@
-import os
-import pytest
+import os
+import pytest
import six
-
-
-MAX_ALLOWED_LINKS_COUNT = 10
-
-
-@pytest.fixture
-def metrics(request):
-
- class Metrics(object):
- @classmethod
- def set(cls, name, value):
- assert len(name) <= 128, "Length of the metric name must less than 128"
- assert type(value) in [int, float], "Metric value must be of type int or float"
- test_name = request.node.nodeid
- if test_name not in request.config.test_metrics:
- request.config.test_metrics[test_name] = {}
- request.config.test_metrics[test_name][name] = value
-
- @classmethod
- def set_benchmark(cls, benchmark_values):
+
+
+MAX_ALLOWED_LINKS_COUNT = 10
+
+
+@pytest.fixture
+def metrics(request):
+
+ class Metrics(object):
+ @classmethod
+ def set(cls, name, value):
+ assert len(name) <= 128, "Length of the metric name must less than 128"
+ assert type(value) in [int, float], "Metric value must be of type int or float"
+ test_name = request.node.nodeid
+ if test_name not in request.config.test_metrics:
+ request.config.test_metrics[test_name] = {}
+ request.config.test_metrics[test_name][name] = value
+
+ @classmethod
+ def set_benchmark(cls, benchmark_values):
# report of google has key 'benchmarks' which is a list of benchmark results
# yandex benchmark has key 'benchmark', which is a list of benchmark results
# use this to differentiate which kind of result it is
@@ -31,12 +31,12 @@ def metrics(request):
@classmethod
def set_ybenchmark(cls, benchmark_values):
- for benchmark in benchmark_values["benchmark"]:
- name = benchmark["name"]
+ for benchmark in benchmark_values["benchmark"]:
+ name = benchmark["name"]
for key, value in six.iteritems(benchmark):
- if key != "name":
- cls.set("{}_{}".format(name, key), value)
-
+ if key != "name":
+ cls.set("{}_{}".format(name, key), value)
+
@classmethod
def set_gbenchmark(cls, benchmark_values):
time_unit_multipliers = {"ns": 1, "us": 1000, "ms": 1000000}
@@ -50,36 +50,36 @@ def metrics(request):
cls.set("{}_{}".format(name, k), v * time_unit_mult)
elif k not in ignore_keys and isinstance(v, (float, int)):
cls.set("{}_{}".format(name, k), v)
- return Metrics
-
-
-@pytest.fixture
-def links(request):
-
- class Links(object):
- @classmethod
- def set(cls, name, path):
-
- if len(request.config.test_logs[request.node.nodeid]) >= MAX_ALLOWED_LINKS_COUNT:
- raise Exception("Cannot add more than {} links to test".format(MAX_ALLOWED_LINKS_COUNT))
-
- reserved_names = ["log", "logsdir", "stdout", "stderr"]
- if name in reserved_names:
- raise Exception("Attachment name should not belong to the reserved list: {}".format(", ".join(reserved_names)))
- output_dir = request.config.ya.output_dir
-
- if not os.path.exists(path):
- raise Exception("Path to be attached does not exist: {}".format(path))
-
- if os.path.isabs(path) and ".." in os.path.relpath(path, output_dir):
- raise Exception("Test attachment must be inside yatest.common.output_path()")
-
- request.config.test_logs[request.node.nodeid][name] = path
-
- @classmethod
- def get(cls, name):
- if name not in request.config.test_logs[request.node.nodeid]:
- raise KeyError("Attachment with name '{}' does not exist".format(name))
- return request.config.test_logs[request.node.nodeid][name]
-
- return Links
+ return Metrics
+
+
+@pytest.fixture
+def links(request):
+
+ class Links(object):
+ @classmethod
+ def set(cls, name, path):
+
+ if len(request.config.test_logs[request.node.nodeid]) >= MAX_ALLOWED_LINKS_COUNT:
+ raise Exception("Cannot add more than {} links to test".format(MAX_ALLOWED_LINKS_COUNT))
+
+ reserved_names = ["log", "logsdir", "stdout", "stderr"]
+ if name in reserved_names:
+ raise Exception("Attachment name should not belong to the reserved list: {}".format(", ".join(reserved_names)))
+ output_dir = request.config.ya.output_dir
+
+ if not os.path.exists(path):
+ raise Exception("Path to be attached does not exist: {}".format(path))
+
+ if os.path.isabs(path) and ".." in os.path.relpath(path, output_dir):
+ raise Exception("Test attachment must be inside yatest.common.output_path()")
+
+ request.config.test_logs[request.node.nodeid][name] = path
+
+ @classmethod
+ def get(cls, name):
+ if name not in request.config.test_logs[request.node.nodeid]:
+ raise KeyError("Attachment with name '{}' does not exist".format(name))
+ return request.config.test_logs[request.node.nodeid][name]
+
+ return Links