diff options
author | abodrov <abodrov@yandex-team.ru> | 2022-02-10 16:47:18 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:18 +0300 |
commit | 1b8c043abfc689b3d27384c4202b20031fc4ae31 (patch) | |
tree | 43ffe3a7cfe51a083e22d9eabb71c4f5321f6b08 /library/python/testing | |
parent | e7a025f6f4917a3eb54227db101e58bb26ee2cfa (diff) | |
download | ydb-1b8c043abfc689b3d27384c4202b20031fc4ae31.tar.gz |
Restoring authorship annotation for <abodrov@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/python/testing')
4 files changed, 21 insertions, 21 deletions
diff --git a/library/python/testing/yatest_common/yatest/common/canonical.py b/library/python/testing/yatest_common/yatest/common/canonical.py index b6a136d3e9..4943ae1a87 100644 --- a/library/python/testing/yatest_common/yatest/common/canonical.py +++ b/library/python/testing/yatest_common/yatest/common/canonical.py @@ -3,8 +3,8 @@ import logging import shutil import tempfile -import six - +import six + from . import process from . import runtime from . import path @@ -15,7 +15,7 @@ yatest_logger = logging.getLogger("ya.test") def _copy(src, dst, universal_lines=False): if universal_lines: with open(dst, "wb") as f: - for line in open(src, "rbU"): + for line in open(src, "rbU"): f.write(line) return shutil.copy(src, dst) @@ -146,7 +146,7 @@ def canonical_py_execute( def _prepare_args(args): if args is None: args = [] - if isinstance(args, six.string_types): + if isinstance(args, six.string_types): args = map(lambda a: a.strip(), args.split()) return args @@ -165,12 +165,12 @@ def _canonical_execute(excutor, kwargs, file_name, save_locally, diff_tool, diff except OSError: pass - with open(out_file_path, "wb") as out_file: + with open(out_file_path, "wb") as out_file: yatest_logger.debug("Will store file in %s", out_file_path) out_file.write(res.std_out) if res.std_err: - with open(err_file_path, "wb") as err_file: + with open(err_file_path, "wb") as err_file: err_file.write(res.std_err) return canonical_file(out_file_path, local=save_locally, diff_tool=diff_tool, diff_file_name=diff_file_name, diff_tool_timeout=diff_tool_timeout) diff --git a/library/python/testing/yatest_common/yatest/common/network.py b/library/python/testing/yatest_common/yatest/common/network.py index 37bcb1b8e0..3ef1e68915 100644 --- a/library/python/testing/yatest_common/yatest/common/network.py +++ b/library/python/testing/yatest_common/yatest/common/network.py @@ -8,8 +8,8 @@ import logging import platform import threading -import six - +import six + UI16MAXVAL = (1 << 16) - 1 logger = logging.getLogger(__name__) @@ -144,7 +144,7 @@ class PortManager(object): raise PortManagerException("All valid ports are taken ({}): {}".format(self._valid_range, self._filelocks)) salt = random.randint(0, UI16MAXVAL) - for attempt in six.moves.range(self._valid_port_count): + for attempt in six.moves.range(self._valid_port_count): probe_port = (salt + attempt) % self._valid_port_count for left, right in self._valid_range: diff --git a/library/python/testing/yatest_common/yatest/common/process.py b/library/python/testing/yatest_common/yatest/common/process.py index a8bcc21f51..d4084c5c64 100644 --- a/library/python/testing/yatest_common/yatest/common/process.py +++ b/library/python/testing/yatest_common/yatest/common/process.py @@ -11,8 +11,8 @@ import subprocess import errno import distutils.version -import six - +import six + try: # yatest.common should try to be hermetic, otherwise, PYTEST_SCRIPT (aka USE_ARCADIA_PYTHON=no) won't work. import library.python.cores as cores @@ -37,17 +37,17 @@ def truncate(s, size): elif len(s) <= size: return s else: - return (b'...' if isinstance(s, bytes) else '...') + s[-(size - 3):] + return (b'...' if isinstance(s, bytes) else '...') + s[-(size - 3):] def get_command_name(command): - return os.path.basename(command.split()[0] if isinstance(command, six.string_types) else command[0]) + return os.path.basename(command.split()[0] if isinstance(command, six.string_types) else command[0]) class ExecutionError(Exception): def __init__(self, execution_result): - if not isinstance(execution_result.command, six.string_types): + if not isinstance(execution_result.command, six.string_types): command = " ".join(str(arg) for arg in execution_result.command) else: command = execution_result.command @@ -228,7 +228,7 @@ class _Execution(object): yatest_logger.debug("Command (pid %s) rc: %s", self._process.pid, self.exit_code) yatest_logger.debug("Command (pid %s) elapsed time (sec): %s", self._process.pid, self.elapsed) if self._metrics: - for key, value in six.iteritems(self._metrics): + for key, value in six.iteritems(self._metrics): yatest_logger.debug("Command (pid %s) %s: %s", self._process.pid, key, value) # Since this code is Python2/3 compatible, we don't know is _std_out/_std_err is real bytes or bytes-str. @@ -270,7 +270,7 @@ class _Execution(object): if os.path.exists(runtime.gdb_path()): self._backtrace = cores.get_gdb_full_backtrace(self.command[0], core_path, runtime.gdb_path()) bt_filename = path.get_unique_file_path(runtime.output_path(), "{}.{}.backtrace".format(os.path.basename(self.command[0]), self._process.pid)) - with open(bt_filename, "wb") as afile: + with open(bt_filename, "wb") as afile: afile.write(six.ensure_binary(self._backtrace)) # generate pretty html version of backtrace aka Tri Korochki pbt_filename = bt_filename + ".html" @@ -473,7 +473,7 @@ def execute( # No stream is supplied: open new temp file return _get_command_output_file(command, default_name), False - if isinstance(stream, six.string_types): + if isinstance(stream, six.string_types): # User filename is supplied: open file for writing return open(stream, 'wb+'), stream.startswith('/dev/') @@ -586,7 +586,7 @@ def py_execute( :param process_progress_listener=object that is polled while execution is in progress :return _Execution: Execution object """ - if isinstance(command, six.string_types): + if isinstance(command, six.string_types): command = [command] command = [runtime.python_path()] + command if shell: diff --git a/library/python/testing/yatest_common/yatest/common/runtime.py b/library/python/testing/yatest_common/yatest/common/runtime.py index e55e193446..b96f17a53d 100644 --- a/library/python/testing/yatest_common/yatest/common/runtime.py +++ b/library/python/testing/yatest_common/yatest/common/runtime.py @@ -4,9 +4,9 @@ import json import os import threading -import six - +import six + _lock = threading.Lock() @@ -34,7 +34,7 @@ def _get_ya_plugin_instance(): def _norm_path(path): if path is None: return None - assert isinstance(path, six.string_types) + assert isinstance(path, six.string_types) if "\\" in path: raise AssertionError("path {} contains Windows seprators \\ - replace them with '/'".format(path)) return os.path.normpath(path) |