diff options
author | dvshkurko <dvshkurko@yandex-team.ru> | 2022-02-10 16:45:52 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:52 +0300 |
commit | c768a99151e47c3a4bb7b92c514d256abd301c4d (patch) | |
tree | 1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /library/python/testing/yatest_common/yatest | |
parent | 321ee9bce31ec6e238be26dbcbe539cffa2c3309 (diff) | |
download | ydb-c768a99151e47c3a4bb7b92c514d256abd301c4d.tar.gz |
Restoring authorship annotation for <dvshkurko@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/python/testing/yatest_common/yatest')
-rw-r--r-- | library/python/testing/yatest_common/yatest/common/path.py | 60 | ||||
-rw-r--r-- | library/python/testing/yatest_common/yatest/common/runtime.py | 18 |
2 files changed, 39 insertions, 39 deletions
diff --git a/library/python/testing/yatest_common/yatest/common/path.py b/library/python/testing/yatest_common/yatest/common/path.py index 1d08f72e62..6fed7dda8a 100644 --- a/library/python/testing/yatest_common/yatest/common/path.py +++ b/library/python/testing/yatest_common/yatest/common/path.py @@ -1,13 +1,13 @@ # coding=utf-8 -import errno +import errno import os import shutil import contextlib -import library.python.fs as lpf +import library.python.fs as lpf + - def replace_in_file(path, old, new): """ Replace text occurrences in a file @@ -18,7 +18,7 @@ def replace_in_file(path, old, new): with open(path) as fp: content = fp.read() - lpf.ensure_removed(path) + lpf.ensure_removed(path) with open(path, 'w') as fp: fp.write(content.replace(old, new)) @@ -56,35 +56,35 @@ def copytree(src, dst, symlinks=False, ignore=None, postprocessing=None): postprocessing(os.path.join(root, path), True) -def get_unique_file_path(dir_path, file_pattern, create_file=True, max_suffix=10000): - def atomic_file_create(path): - try: +def get_unique_file_path(dir_path, file_pattern, create_file=True, max_suffix=10000): + def atomic_file_create(path): + try: fd = os.open(path, os.O_CREAT | os.O_EXCL, 0o644) - os.close(fd) - return True - except OSError as e: - if e.errno in [errno.EEXIST, errno.EISDIR, errno.ETXTBSY]: - return False - # Access issue with file itself, not parent directory. - if e.errno == errno.EACCES and os.path.exists(path): - return False - raise e - - def atomic_dir_create(path): - try: - os.mkdir(path) - return True - except OSError as e: - if e.errno == errno.EEXIST: - return False - raise e - + os.close(fd) + return True + except OSError as e: + if e.errno in [errno.EEXIST, errno.EISDIR, errno.ETXTBSY]: + return False + # Access issue with file itself, not parent directory. + if e.errno == errno.EACCES and os.path.exists(path): + return False + raise e + + def atomic_dir_create(path): + try: + os.mkdir(path) + return True + except OSError as e: + if e.errno == errno.EEXIST: + return False + raise e + file_path = os.path.join(dir_path, file_pattern) - lpf.ensure_dir(os.path.dirname(file_path)) + lpf.ensure_dir(os.path.dirname(file_path)) file_counter = 0 - handler = atomic_file_create if create_file else atomic_dir_create - while os.path.exists(file_path) or not handler(file_path): + handler = atomic_file_create if create_file else atomic_dir_create + while os.path.exists(file_path) or not handler(file_path): file_path = os.path.join(dir_path, file_pattern + ".{}".format(file_counter)) file_counter += 1 - assert file_counter < max_suffix + assert file_counter < max_suffix return file_path diff --git a/library/python/testing/yatest_common/yatest/common/runtime.py b/library/python/testing/yatest_common/yatest/common/runtime.py index 95d96b468a..e55e193446 100644 --- a/library/python/testing/yatest_common/yatest/common/runtime.py +++ b/library/python/testing/yatest_common/yatest/common/runtime.py @@ -2,14 +2,14 @@ import errno import functools import json import os -import threading +import threading import six -_lock = threading.Lock() - - +_lock = threading.Lock() + + def _get_ya_config(): try: import library.python.pytest.plugins.ya as ya_plugin @@ -263,13 +263,13 @@ def global_resources(): def _register_core(name, binary_path, core_path, bt_path, pbt_path): config = _get_ya_config() - - with _lock: + + with _lock: if not hasattr(config, 'test_cores_count'): config.test_cores_count = 0 - config.test_cores_count += 1 - count_str = '' if config.test_cores_count == 1 else str(config.test_cores_count) - + config.test_cores_count += 1 + count_str = '' if config.test_cores_count == 1 else str(config.test_cores_count) + log_entry = config.test_logs[config.current_item_nodeid] if binary_path: log_entry['{} binary{}'.format(name, count_str)] = binary_path |