aboutsummaryrefslogtreecommitdiffstats
path: root/library/python/testing
diff options
context:
space:
mode:
authorasatarin <asatarin@yandex-team.ru>2022-02-10 16:47:30 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:47:30 +0300
commit4ca29390ac54b7877174de542de47532c67453b5 (patch)
tree14f6fc2edf989ce65a7555e8882e3eae3e9306fe /library/python/testing
parent05f59b2581f074c756adaee6b260014ac3a0c3ec (diff)
downloadydb-4ca29390ac54b7877174de542de47532c67453b5.tar.gz
Restoring authorship annotation for <asatarin@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/python/testing')
-rw-r--r--library/python/testing/yatest_common/yatest/common/network.py8
-rw-r--r--library/python/testing/yatest_common/yatest/common/process.py20
-rw-r--r--library/python/testing/yatest_common/yatest/common/runtime.py28
-rw-r--r--library/python/testing/yatest_lib/test_splitter.py92
4 files changed, 74 insertions, 74 deletions
diff --git a/library/python/testing/yatest_common/yatest/common/network.py b/library/python/testing/yatest_common/yatest/common/network.py
index 37bcb1b8e0..ef33444dad 100644
--- a/library/python/testing/yatest_common/yatest/common/network.py
+++ b/library/python/testing/yatest_common/yatest/common/network.py
@@ -19,12 +19,12 @@ class PortManagerException(Exception):
class PortManager(object):
- """
- See documentation here
+ """
+ See documentation here
https://wiki.yandex-team.ru/yatool/test/#python-acquire-ports
- """
-
+ """
+
def __init__(self, sync_dir=None):
self._sync_dir = sync_dir or os.environ.get('PORT_SYNC_PATH')
if self._sync_dir:
diff --git a/library/python/testing/yatest_common/yatest/common/process.py b/library/python/testing/yatest_common/yatest/common/process.py
index a8bcc21f51..d56eeb3f75 100644
--- a/library/python/testing/yatest_common/yatest/common/process.py
+++ b/library/python/testing/yatest_common/yatest/common/process.py
@@ -356,7 +356,7 @@ class _Execution(object):
finally:
self._elapsed = time.time() - self._start
self._save_outputs()
- self.verify_no_coredumps()
+ self.verify_no_coredumps()
self._finalise(check_exit_code)
@@ -370,11 +370,11 @@ class _Execution(object):
# Don't search for sanitize errors if stderr was redirected
self.verify_sanitize_errors()
- def verify_no_coredumps(self):
- """
- Verify there is no coredump from this binary. If there is then report backtrace.
- """
- if self.exit_code < 0 and self._collect_cores:
+ def verify_no_coredumps(self):
+ """
+ Verify there is no coredump from this binary. If there is then report backtrace.
+ """
+ if self.exit_code < 0 and self._collect_cores:
if cores:
try:
self._recover_core()
@@ -382,11 +382,11 @@ class _Execution(object):
yatest_logger.exception("Exception while recovering core")
else:
yatest_logger.warning("Core dump file recovering is skipped: module cores isn't available")
-
+
def verify_sanitize_errors(self):
- """
- Verify there are no sanitizer (ASAN, MSAN, TSAN, etc) errors for this binary. If there are any report them.
- """
+ """
+ Verify there are no sanitizer (ASAN, MSAN, TSAN, etc) errors for this binary. If there are any report them.
+ """
if self._std_err and self._check_sanitizer and runtime._get_ya_config().sanitizer_extra_checks:
build_path = runtime.build_path()
if self.command[0].startswith(build_path):
diff --git a/library/python/testing/yatest_common/yatest/common/runtime.py b/library/python/testing/yatest_common/yatest/common/runtime.py
index e55e193446..c827169f43 100644
--- a/library/python/testing/yatest_common/yatest/common/runtime.py
+++ b/library/python/testing/yatest_common/yatest/common/runtime.py
@@ -198,15 +198,15 @@ def get_param(key, default=None):
return _get_ya_plugin_instance().get_param(key, default)
-def get_param_dict_copy():
- """
- Return copy of dictionary with all parameters. Changes to this dictionary do *not* change parameters.
-
- :return: copy of dictionary with all parameters
- """
- return _get_ya_plugin_instance().get_param_dict_copy()
-
-
+def get_param_dict_copy():
+ """
+ Return copy of dictionary with all parameters. Changes to this dictionary do *not* change parameters.
+
+ :return: copy of dictionary with all parameters
+ """
+ return _get_ya_plugin_instance().get_param_dict_copy()
+
+
@not_test
def test_output_path(path=None):
"""
@@ -317,11 +317,11 @@ class Context(object):
@property
def sanitize(self):
- """
- Detect if current test run is under sanitizer
-
- :return: one of `None`, 'address', 'memory', 'thread', 'undefined'
- """
+ """
+ Detect if current test run is under sanitizer
+
+ :return: one of `None`, 'address', 'memory', 'thread', 'undefined'
+ """
return _get_ya_plugin_instance().get_context("sanitize")
@property
diff --git a/library/python/testing/yatest_lib/test_splitter.py b/library/python/testing/yatest_lib/test_splitter.py
index acbcd4300e..ba90a47291 100644
--- a/library/python/testing/yatest_lib/test_splitter.py
+++ b/library/python/testing/yatest_lib/test_splitter.py
@@ -1,50 +1,50 @@
# coding: utf-8
-
-import collections
-
-
+
+import collections
+
+
def flatten_tests(test_classes):
- """
- >>> test_classes = {x: [x] for x in range(5)}
+ """
+ >>> test_classes = {x: [x] for x in range(5)}
>>> flatten_tests(test_classes)
- [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4)]
- >>> test_classes = {x: [x + 1, x + 2] for x in range(2)}
+ [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4)]
+ >>> test_classes = {x: [x + 1, x + 2] for x in range(2)}
>>> flatten_tests(test_classes)
- [(0, 1), (0, 2), (1, 2), (1, 3)]
- """
- tests = []
- for class_name, test_names in test_classes.items():
- tests += [(class_name, test_name) for test_name in test_names]
- return tests
-
-
+ [(0, 1), (0, 2), (1, 2), (1, 3)]
+ """
+ tests = []
+ for class_name, test_names in test_classes.items():
+ tests += [(class_name, test_name) for test_name in test_names]
+ return tests
+
+
def get_sequential_chunk(tests, modulo, modulo_index, is_sorted=False):
- """
+ """
>>> get_sequential_chunk(range(10), 4, 0)
- [0, 1, 2]
+ [0, 1, 2]
>>> get_sequential_chunk(range(10), 4, 1)
- [3, 4, 5]
+ [3, 4, 5]
>>> get_sequential_chunk(range(10), 4, 2)
[6, 7]
>>> get_sequential_chunk(range(10), 4, 3)
[8, 9]
>>> get_sequential_chunk(range(10), 4, 4)
- []
+ []
>>> get_sequential_chunk(range(10), 4, 5)
- []
- """
+ []
+ """
if not is_sorted:
tests = sorted(tests)
chunk_size = len(tests) // modulo
not_used = len(tests) % modulo
shift = chunk_size + (modulo_index < not_used)
start = chunk_size * modulo_index + min(modulo_index, not_used)
- end = start + shift
+ end = start + shift
return [] if end > len(tests) else tests[start:end]
-
-
+
+
def get_shuffled_chunk(tests, modulo, modulo_index, is_sorted=False):
- """
+ """
>>> get_shuffled_chunk(range(10), 4, 0)
[0, 4, 8]
>>> get_shuffled_chunk(range(10), 4, 1)
@@ -78,25 +78,25 @@ def get_splitted_tests(test_entities, modulo, modulo_index, partition_mode, is_s
def filter_tests_by_modulo(test_classes, modulo, modulo_index, split_by_tests, partition_mode="SEQUENTIAL"):
"""
- >>> test_classes = {x: [x] for x in range(20)}
- >>> filter_tests_by_modulo(test_classes, 4, 0, False)
- {0: [0], 1: [1], 2: [2], 3: [3], 4: [4]}
- >>> filter_tests_by_modulo(test_classes, 4, 1, False)
- {8: [8], 9: [9], 5: [5], 6: [6], 7: [7]}
- >>> filter_tests_by_modulo(test_classes, 4, 2, False)
- {10: [10], 11: [11], 12: [12], 13: [13], 14: [14]}
-
- >>> dict(filter_tests_by_modulo(test_classes, 4, 0, True))
- {0: [0], 1: [1], 2: [2], 3: [3], 4: [4]}
- >>> dict(filter_tests_by_modulo(test_classes, 4, 1, True))
- {8: [8], 9: [9], 5: [5], 6: [6], 7: [7]}
- """
- if split_by_tests:
+ >>> test_classes = {x: [x] for x in range(20)}
+ >>> filter_tests_by_modulo(test_classes, 4, 0, False)
+ {0: [0], 1: [1], 2: [2], 3: [3], 4: [4]}
+ >>> filter_tests_by_modulo(test_classes, 4, 1, False)
+ {8: [8], 9: [9], 5: [5], 6: [6], 7: [7]}
+ >>> filter_tests_by_modulo(test_classes, 4, 2, False)
+ {10: [10], 11: [11], 12: [12], 13: [13], 14: [14]}
+
+ >>> dict(filter_tests_by_modulo(test_classes, 4, 0, True))
+ {0: [0], 1: [1], 2: [2], 3: [3], 4: [4]}
+ >>> dict(filter_tests_by_modulo(test_classes, 4, 1, True))
+ {8: [8], 9: [9], 5: [5], 6: [6], 7: [7]}
+ """
+ if split_by_tests:
tests = get_splitted_tests(flatten_tests(test_classes), modulo, modulo_index, partition_mode)
- test_classes = collections.defaultdict(list)
- for class_name, test_name in tests:
- test_classes[class_name].append(test_name)
- return test_classes
- else:
+ test_classes = collections.defaultdict(list)
+ for class_name, test_name in tests:
+ test_classes[class_name].append(test_name)
+ return test_classes
+ else:
target_classes = get_splitted_tests(test_classes, modulo, modulo_index, partition_mode)
- return {class_name: test_classes[class_name] for class_name in target_classes}
+ return {class_name: test_classes[class_name] for class_name in target_classes}