diff options
author | shadchin <shadchin@yandex-team.ru> | 2022-02-10 16:44:39 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:39 +0300 |
commit | e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (patch) | |
tree | 64175d5cadab313b3e7039ebaa06c5bc3295e274 /library/python | |
parent | 2598ef1d0aee359b4b6d5fdd1758916d5907d04f (diff) | |
download | ydb-e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0.tar.gz |
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/python')
30 files changed, 500 insertions, 500 deletions
diff --git a/library/python/certifi/.dist-info/METADATA b/library/python/certifi/.dist-info/METADATA index 4fec05a2ec..4849f81ed4 100644 --- a/library/python/certifi/.dist-info/METADATA +++ b/library/python/certifi/.dist-info/METADATA @@ -1,2 +1,2 @@ -Name: certifi +Name: certifi Version: 2019.7.1 diff --git a/library/python/certifi/.dist-info/top_level.txt b/library/python/certifi/.dist-info/top_level.txt index a4dd224008..963eac530b 100644 --- a/library/python/certifi/.dist-info/top_level.txt +++ b/library/python/certifi/.dist-info/top_level.txt @@ -1 +1 @@ -certifi +certifi diff --git a/library/python/certifi/certifi/__init__.py b/library/python/certifi/certifi/__init__.py index d4a67980cf..5270d206cd 100644 --- a/library/python/certifi/certifi/__init__.py +++ b/library/python/certifi/certifi/__init__.py @@ -5,6 +5,6 @@ if hasattr(ssl, 'builtin_cadata'): else: from .source import where -__all__ = ['where', '__version__'] - -__version__ = '2020.04.05.2' +__all__ = ['where', '__version__'] + +__version__ = '2020.04.05.2' diff --git a/library/python/certifi/ya.make b/library/python/certifi/ya.make index 797adfbda9..64fefe2833 100644 --- a/library/python/certifi/ya.make +++ b/library/python/certifi/ya.make @@ -2,12 +2,12 @@ PY23_LIBRARY() OWNER(orivej g:python-contrib) -RESOURCE_FILES( +RESOURCE_FILES( PREFIX library/python/certifi/ - .dist-info/METADATA - .dist-info/top_level.txt -) - + .dist-info/METADATA + .dist-info/top_level.txt +) + PY_SRCS( TOP_LEVEL certifi/__init__.py diff --git a/library/python/filelock/__init__.py b/library/python/filelock/__init__.py index c284a3fbdc..f81ff67f37 100644 --- a/library/python/filelock/__init__.py +++ b/library/python/filelock/__init__.py @@ -58,11 +58,11 @@ class _NixFileLock(AbstractFileLock): def release(self): self._unlocker(self._lock) - def __del__(self): - if hasattr(self, "_lock"): - self._lock.close() + def __del__(self): + if hasattr(self, "_lock"): + self._lock.close() + - class _WinFileLock(AbstractFileLock): """ Based on LockFile / UnlockFile from win32 API diff --git a/library/python/pytest/plugins/collection.py b/library/python/pytest/plugins/collection.py index 7e7984dc69..e36f47a78f 100644 --- a/library/python/pytest/plugins/collection.py +++ b/library/python/pytest/plugins/collection.py @@ -1,4 +1,4 @@ -import os +import os import sys from six import reraise @@ -34,9 +34,9 @@ class LoadedModule(_pytest.python.Module): @property def _nodeid(self): if os.getenv('CONFTEST_LOAD_POLICY') == 'LOCAL': - return self._getobj().__file__ - else: - return self.name + return self._getobj().__file__ + else: + return self.name @property def nodeid(self): diff --git a/library/python/pytest/plugins/conftests.py b/library/python/pytest/plugins/conftests.py index 01c4ae3b42..522041f5a7 100644 --- a/library/python/pytest/plugins/conftests.py +++ b/library/python/pytest/plugins/conftests.py @@ -1,10 +1,10 @@ -import os +import os import importlib import sys import inspect - -from pytest import hookimpl - + +from pytest import hookimpl + from .fixtures import metrics, links # noqa orig_getfile = inspect.getfile @@ -21,8 +21,8 @@ inspect.getfile = getfile conftest_modules = [] -@hookimpl(trylast=True) -def pytest_load_initial_conftests(early_config, parser, args): +@hookimpl(trylast=True) +def pytest_load_initial_conftests(early_config, parser, args): conftests = filter(lambda name: name.endswith(".conftest"), sys.extra_modules) def conftest_key(name): @@ -33,11 +33,11 @@ def pytest_load_initial_conftests(early_config, parser, args): for name in sorted(conftests, key=conftest_key): mod = importlib.import_module(name) - if os.getenv("CONFTEST_LOAD_POLICY") != "LOCAL": - mod.__orig_file__ = mod.__file__ - mod.__file__ = "" + if os.getenv("CONFTEST_LOAD_POLICY") != "LOCAL": + mod.__orig_file__ = mod.__file__ + mod.__file__ = "" conftest_modules.append(mod) - early_config.pluginmanager.consider_conftest(mod) + early_config.pluginmanager.consider_conftest(mod) def getconftestmodules(*args, **kwargs): diff --git a/library/python/pytest/plugins/ya.py b/library/python/pytest/plugins/ya.py index e34f618fc5..1bde03042d 100644 --- a/library/python/pytest/plugins/ya.py +++ b/library/python/pytest/plugins/ya.py @@ -11,23 +11,23 @@ import json import time import traceback import collections -import signal -import inspect -import warnings - -import attr -import faulthandler +import signal +import inspect +import warnings + +import attr +import faulthandler import py import pytest -import six - +import six + import _pytest -import _pytest._io +import _pytest._io import _pytest.mark -import _pytest.outcomes +import _pytest.outcomes import _pytest.skipping -from _pytest.warning_types import PytestUnhandledCoroutineWarning +from _pytest.warning_types import PytestUnhandledCoroutineWarning from yatest_lib import test_splitter @@ -63,9 +63,9 @@ yatest_logger = logging.getLogger("ya.test") _pytest.main.EXIT_NOTESTSCOLLECTED = 0 SHUTDOWN_REQUESTED = False -pytest_config = None +pytest_config = None + - def configure_pdb_on_demand(): import signal @@ -128,7 +128,7 @@ def setup_logging(log_path, level=logging.DEBUG, *other_logs): root_logger = logging.getLogger() for i in range(len(root_logger.handlers) - 1, -1, -1): if isinstance(root_logger.handlers[i], YaTestLoggingFileHandler): - root_logger.handlers.pop(i).close() + root_logger.handlers.pop(i).close() root_logger.setLevel(level) for log_file in logs: file_handler = YaTestLoggingFileHandler(log_file) @@ -182,13 +182,13 @@ def from_ya_test(): def pytest_configure(config): - global pytest_config - pytest_config = config - + global pytest_config + pytest_config = config + config.option.continue_on_collection_errors = True - config.addinivalue_line("markers", "ya:external") - + config.addinivalue_line("markers", "ya:external") + config.from_ya_test = from_ya_test() config.test_logs = collections.defaultdict(dict) config.test_metrics = {} @@ -248,8 +248,8 @@ def pytest_configure(config): os.environ[envvar] = os.environ[envvar + '_ORIGINAL'] if config.option.root_dir: - config.rootdir = py.path.local(config.option.root_dir) - config.invocation_params = attr.evolve(config.invocation_params, dir=config.rootdir) + config.rootdir = py.path.local(config.option.root_dir) + config.invocation_params = attr.evolve(config.invocation_params, dir=config.rootdir) extra_sys_path = [] # Arcadia paths from the test DEPENDS section of ya.make @@ -334,7 +334,7 @@ def _get_rusage(): def _collect_test_rusage(item): if resource and hasattr(item, "rusage"): finish_rusage = _get_rusage() - ya_inst = pytest_config.ya + ya_inst = pytest_config.ya def add_metric(attr_name, metric_name=None, modifier=None): if not metric_name: @@ -369,37 +369,37 @@ def _get_item_tags(item): tags = [] for key, value in item.keywords.items(): if key == 'pytestmark' and isinstance(value, list): - for mark in value: - tags.append(mark.name) - elif isinstance(value, _pytest.mark.MarkDecorator): + for mark in value: + tags.append(mark.name) + elif isinstance(value, _pytest.mark.MarkDecorator): tags.append(key) return tags def pytest_runtest_setup(item): item.rusage = _get_rusage() - pytest_config.test_cores_count = 0 - pytest_config.current_item_nodeid = item.nodeid + pytest_config.test_cores_count = 0 + pytest_config.current_item_nodeid = item.nodeid class_name, test_name = tools.split_node_id(item.nodeid) - test_log_path = tools.get_test_log_file_path(pytest_config.ya.output_dir, class_name, test_name) + test_log_path = tools.get_test_log_file_path(pytest_config.ya.output_dir, class_name, test_name) setup_logging( - os.path.join(pytest_config.ya.output_dir, "run.log"), - pytest_config.option.test_log_level, + os.path.join(pytest_config.ya.output_dir, "run.log"), + pytest_config.option.test_log_level, test_log_path ) - pytest_config.test_logs[item.nodeid]['log'] = test_log_path - pytest_config.test_logs[item.nodeid]['logsdir'] = pytest_config.ya.output_dir - pytest_config.current_test_log_path = test_log_path - pytest_config.current_test_name = "{}::{}".format(class_name, test_name) + pytest_config.test_logs[item.nodeid]['log'] = test_log_path + pytest_config.test_logs[item.nodeid]['logsdir'] = pytest_config.ya.output_dir + pytest_config.current_test_log_path = test_log_path + pytest_config.current_test_name = "{}::{}".format(class_name, test_name) separator = "#" * 100 yatest_logger.info(separator) yatest_logger.info(test_name) yatest_logger.info(separator) yatest_logger.info("Test setup") - test_item = CrashedTestItem(item.nodeid, pytest_config.option.test_suffix) - pytest_config.ya_trace_reporter.on_start_test_class(test_item) - pytest_config.ya_trace_reporter.on_start_test_case(test_item) + test_item = CrashedTestItem(item.nodeid, pytest_config.option.test_suffix) + pytest_config.ya_trace_reporter.on_start_test_class(test_item) + pytest_config.ya_trace_reporter.on_start_test_case(test_item) def pytest_runtest_teardown(item, nextitem): @@ -412,7 +412,7 @@ def pytest_runtest_call(item): def pytest_deselected(items): - config = pytest_config + config = pytest_config if config.option.report_deselected: for item in items: deselected_item = DeselectedTestItem(item.nodeid, config.option.test_suffix) @@ -428,7 +428,7 @@ def pytest_collection_modifyitems(items, config): filtered_items = [] deselected_items = [] for item in items: - canonical_node_id = str(CustomTestItem(item.nodeid, pytest_config.option.test_suffix)) + canonical_node_id = str(CustomTestItem(item.nodeid, pytest_config.option.test_suffix)) matched = False for flt in filters: if "::" not in flt and "*" not in flt: @@ -500,7 +500,7 @@ def pytest_collection_modifyitems(items, config): elif config.option.mode == yatest_lib.ya.RunMode.List: tests = [] for item in items: - item = CustomTestItem(item.nodeid, pytest_config.option.test_suffix, item.keywords) + item = CustomTestItem(item.nodeid, pytest_config.option.test_suffix, item.keywords) record = { "class": item.class_name, "test": item.test_name, @@ -516,9 +516,9 @@ def pytest_collection_modifyitems(items, config): def pytest_collectreport(report): if not report.passed: - if hasattr(pytest_config, 'ya_trace_reporter'): - test_item = TestItem(report, None, pytest_config.option.test_suffix) - pytest_config.ya_trace_reporter.on_error(test_item) + if hasattr(pytest_config, 'ya_trace_reporter'): + test_item = TestItem(report, None, pytest_config.option.test_suffix) + pytest_config.ya_trace_reporter.on_error(test_item) else: sys.stderr.write(yatest_lib.tools.to_utf8(report.longrepr)) @@ -526,60 +526,60 @@ def pytest_collectreport(report): @pytest.mark.tryfirst def pytest_pyfunc_call(pyfuncitem): testfunction = pyfuncitem.obj - iscoroutinefunction = getattr(inspect, "iscoroutinefunction", None) - if iscoroutinefunction is not None and iscoroutinefunction(testfunction): - msg = "Coroutine functions are not natively supported and have been skipped.\n" - msg += "You need to install a suitable plugin for your async framework, for example:\n" - msg += " - pytest-asyncio\n" - msg += " - pytest-trio\n" - msg += " - pytest-tornasync" - warnings.warn(PytestUnhandledCoroutineWarning(msg.format(pyfuncitem.nodeid))) - _pytest.outcomes.skip(msg="coroutine function and no async plugin installed (see warnings)") - funcargs = pyfuncitem.funcargs - testargs = {arg: funcargs[arg] for arg in pyfuncitem._fixtureinfo.argnames} - pyfuncitem.retval = testfunction(**testargs) + iscoroutinefunction = getattr(inspect, "iscoroutinefunction", None) + if iscoroutinefunction is not None and iscoroutinefunction(testfunction): + msg = "Coroutine functions are not natively supported and have been skipped.\n" + msg += "You need to install a suitable plugin for your async framework, for example:\n" + msg += " - pytest-asyncio\n" + msg += " - pytest-trio\n" + msg += " - pytest-tornasync" + warnings.warn(PytestUnhandledCoroutineWarning(msg.format(pyfuncitem.nodeid))) + _pytest.outcomes.skip(msg="coroutine function and no async plugin installed (see warnings)") + funcargs = pyfuncitem.funcargs + testargs = {arg: funcargs[arg] for arg in pyfuncitem._fixtureinfo.argnames} + pyfuncitem.retval = testfunction(**testargs) return True @pytest.hookimpl(hookwrapper=True) def pytest_runtest_makereport(item, call): def logreport(report, result, call): - test_item = TestItem(report, result, pytest_config.option.test_suffix) - if not pytest_config.suite_metrics and context.Ctx.get("YA_PYTEST_START_TIMESTAMP"): - pytest_config.suite_metrics["pytest_startup_duration"] = call.start - context.Ctx["YA_PYTEST_START_TIMESTAMP"] - pytest_config.ya_trace_reporter.dump_suite_metrics() + test_item = TestItem(report, result, pytest_config.option.test_suffix) + if not pytest_config.suite_metrics and context.Ctx.get("YA_PYTEST_START_TIMESTAMP"): + pytest_config.suite_metrics["pytest_startup_duration"] = call.start - context.Ctx["YA_PYTEST_START_TIMESTAMP"] + pytest_config.ya_trace_reporter.dump_suite_metrics() - pytest_config.ya_trace_reporter.on_log_report(test_item) + pytest_config.ya_trace_reporter.on_log_report(test_item) if report.outcome == "failed": yatest_logger.error(report.longrepr) if report.when == "call": _collect_test_rusage(item) - pytest_config.ya_trace_reporter.on_finish_test_case(test_item) + pytest_config.ya_trace_reporter.on_finish_test_case(test_item) elif report.when == "setup": - pytest_config.ya_trace_reporter.on_start_test_class(test_item) + pytest_config.ya_trace_reporter.on_start_test_class(test_item) if report.outcome != "passed": - pytest_config.ya_trace_reporter.on_start_test_case(test_item) - pytest_config.ya_trace_reporter.on_finish_test_case(test_item) + pytest_config.ya_trace_reporter.on_start_test_case(test_item) + pytest_config.ya_trace_reporter.on_finish_test_case(test_item) else: - pytest_config.ya_trace_reporter.on_start_test_case(test_item) + pytest_config.ya_trace_reporter.on_start_test_case(test_item) elif report.when == "teardown": if report.outcome == "failed": - pytest_config.ya_trace_reporter.on_start_test_case(test_item) - pytest_config.ya_trace_reporter.on_finish_test_case(test_item) + pytest_config.ya_trace_reporter.on_start_test_case(test_item) + pytest_config.ya_trace_reporter.on_finish_test_case(test_item) else: - pytest_config.ya_trace_reporter.on_finish_test_case(test_item, duration_only=True) - pytest_config.ya_trace_reporter.on_finish_test_class(test_item) + pytest_config.ya_trace_reporter.on_finish_test_case(test_item, duration_only=True) + pytest_config.ya_trace_reporter.on_finish_test_class(test_item) outcome = yield rep = outcome.get_result() result = None if hasattr(item, 'retval') and item.retval is not None: result = item.retval - if not pytest_config.from_ya_test: - ti = TestItem(rep, result, pytest_config.option.test_suffix) - tr = pytest_config.pluginmanager.getplugin('terminalreporter') + if not pytest_config.from_ya_test: + ti = TestItem(rep, result, pytest_config.option.test_suffix) + tr = pytest_config.pluginmanager.getplugin('terminalreporter') tr.write_line("{} - Validating canonical data is not supported when running standalone binary".format(ti), yellow=True, bold=True) logreport(rep, result, call) @@ -604,12 +604,12 @@ def get_formatted_error(report): def colorize(longrepr): # use default pytest colorization - if pytest_config.option.tbstyle != "short": + if pytest_config.option.tbstyle != "short": io = py.io.TextIO() - if six.PY2: - writer = py.io.TerminalWriter(file=io) - else: - writer = _pytest._io.TerminalWriter(file=io) + if six.PY2: + writer = py.io.TerminalWriter(file=io) + else: + writer = _pytest._io.TerminalWriter(file=io) # enable colorization writer.hasmarkup = True @@ -804,13 +804,13 @@ class TraceReportGenerator(object): pass def on_start_test_class(self, test_item): - pytest_config.ya.set_test_item_node_id(test_item.nodeid) + pytest_config.ya.set_test_item_node_id(test_item.nodeid) class_name = test_item.class_name.decode('utf-8') if sys.version_info[0] < 3 else test_item.class_name self._current_test = (class_name, None) self.trace('test-started', {'class': class_name}) def on_finish_test_class(self, test_item): - pytest_config.ya.set_test_item_node_id(test_item.nodeid) + pytest_config.ya.set_test_item_node_id(test_item.nodeid) self.trace('test-finished', {'class': test_item.class_name.decode('utf-8') if sys.version_info[0] < 3 else test_item.class_name}) def on_start_test_case(self, test_item): @@ -820,9 +820,9 @@ class TraceReportGenerator(object): 'class': class_name, 'subtest': subtest_name, } - if test_item.nodeid in pytest_config.test_logs: - message['logs'] = pytest_config.test_logs[test_item.nodeid] - pytest_config.ya.set_test_item_node_id(test_item.nodeid) + if test_item.nodeid in pytest_config.test_logs: + message['logs'] = pytest_config.test_logs[test_item.nodeid] + pytest_config.ya.set_test_item_node_id(test_item.nodeid) self._current_test = (class_name, subtest_name) self.trace('subtest-started', message) @@ -849,12 +849,12 @@ class TraceReportGenerator(object): 'status': test_item.status, 'comment': comment, 'result': result, - 'metrics': pytest_config.test_metrics.get(test_item.nodeid), + 'metrics': pytest_config.test_metrics.get(test_item.nodeid), 'is_diff_test': 'diff_test' in test_item.keywords, 'tags': _get_item_tags(test_item), } - if test_item.nodeid in pytest_config.test_logs: - message['logs'] = pytest_config.test_logs[test_item.nodeid] + if test_item.nodeid in pytest_config.test_logs: + message['logs'] = pytest_config.test_logs[test_item.nodeid] message['time'] = self._test_duration.get(test_item.nodeid, test_item.duration) @@ -862,7 +862,7 @@ class TraceReportGenerator(object): self._test_messages[test_item.nodeid] = message def dump_suite_metrics(self): - message = {"metrics": pytest_config.suite_metrics} + message = {"metrics": pytest_config.suite_metrics} self.trace("suite-event", message) def on_error(self, test_item): diff --git a/library/python/pytest/rewrite.py b/library/python/pytest/rewrite.py index afd0abc782..4cebcb1edd 100644 --- a/library/python/pytest/rewrite.py +++ b/library/python/pytest/rewrite.py @@ -3,13 +3,13 @@ from __future__ import print_function import ast -import py - +import py + from _pytest.assertion import rewrite -try: - import importlib.util -except ImportError: - pass +try: + import importlib.util +except ImportError: + pass try: from pathlib import Path @@ -17,29 +17,29 @@ except ImportError: pass from __res import importer -import sys -import six +import sys +import six + + +def _get_state(config): + if hasattr(config, '_assertstate'): + return config._assertstate + return config._store[rewrite.assertstate_key] -def _get_state(config): - if hasattr(config, '_assertstate'): - return config._assertstate - return config._store[rewrite.assertstate_key] - - class AssertionRewritingHook(rewrite.AssertionRewritingHook): - def __init__(self, *args, **kwargs): - self.modules = {} - super(AssertionRewritingHook, self).__init__(*args, **kwargs) + def __init__(self, *args, **kwargs): + self.modules = {} + super(AssertionRewritingHook, self).__init__(*args, **kwargs) def find_module(self, name, path=None): - co = self._find_module(name, path) - if co is not None: - return self - - def _find_module(self, name, path=None): - state = _get_state(self.config) - if not self._should_rewrite(name, None, state): + co = self._find_module(name, path) + if co is not None: + return self + + def _find_module(self, name, path=None): + state = _get_state(self.config) + if not self._should_rewrite(name, None, state): return None state.trace("find_module called for: %s" % name) @@ -60,18 +60,18 @@ class AssertionRewritingHook(rewrite.AssertionRewritingHook): # Probably a SyntaxError in the test. return None self.modules[name] = co, None - return co - - def find_spec(self, name, path=None, target=None): - co = self._find_module(name, path) - if co is not None: - return importlib.util.spec_from_file_location( - name, - co.co_filename, - loader=self, - ) - - def _should_rewrite(self, name, fn, state): + return co + + def find_spec(self, name, path=None, target=None): + co = self._find_module(name, path) + if co is not None: + return importlib.util.spec_from_file_location( + name, + co.co_filename, + loader=self, + ) + + def _should_rewrite(self, name, fn, state): if name.startswith("__tests__.") or name.endswith(".conftest"): return True @@ -83,31 +83,31 @@ class AssertionRewritingHook(rewrite.AssertionRewritingHook): def get_source(self, name): return importer.get_source(name) - if six.PY3: - def load_module(self, module): - co, _ = self.modules.pop(module.__name__) - try: - module.__file__ = co.co_filename - module.__cached__ = None - module.__loader__ = self - module.__spec__ = importlib.util.spec_from_file_location(module.__name__, co.co_filename, loader=self) - exec(co, module.__dict__) - except: # noqa - if module.__name__ in sys.modules: - del sys.modules[module.__name__] - raise - return sys.modules[module.__name__] - - def exec_module(self, module): - if module.__name__ in self.modules: - self.load_module(module) - else: - super(AssertionRewritingHook, self).exec_module(module) - - + if six.PY3: + def load_module(self, module): + co, _ = self.modules.pop(module.__name__) + try: + module.__file__ = co.co_filename + module.__cached__ = None + module.__loader__ = self + module.__spec__ = importlib.util.spec_from_file_location(module.__name__, co.co_filename, loader=self) + exec(co, module.__dict__) + except: # noqa + if module.__name__ in sys.modules: + del sys.modules[module.__name__] + raise + return sys.modules[module.__name__] + + def exec_module(self, module): + if module.__name__ in self.modules: + self.load_module(module) + else: + super(AssertionRewritingHook, self).exec_module(module) + + def _rewrite_test(config, name): """Try to read and rewrite *fn* and return the code object.""" - state = _get_state(config) + state = _get_state(config) source = importer.get_source(name) if source is None: @@ -121,7 +121,7 @@ def _rewrite_test(config, name): # Let this pop up again in the real import. state.trace("failed to parse: %r" % (path,)) return None - rewrite.rewrite_asserts(tree, py.path.local(path), config) + rewrite.rewrite_asserts(tree, py.path.local(path), config) try: co = compile(tree, path, "exec", dont_inherit=True) except SyntaxError: diff --git a/library/python/runtime_py3/entry_points.py b/library/python/runtime_py3/entry_points.py index 9f099489c0..05098723cb 100644 --- a/library/python/runtime_py3/entry_points.py +++ b/library/python/runtime_py3/entry_points.py @@ -19,7 +19,7 @@ def repl(): if func_name and '__main__' not in user_ns: def run(args): - if isinstance(args, str): + if isinstance(args, str): import shlex args = shlex.split(args) diff --git a/library/python/runtime_py3/importer.pxi b/library/python/runtime_py3/importer.pxi index 6abbb3cf58..904f94dea2 100644 --- a/library/python/runtime_py3/importer.pxi +++ b/library/python/runtime_py3/importer.pxi @@ -333,58 +333,58 @@ class ResourceImporter(object): for m in self.arcadia_source_finder.iter_modules(self._package_prefix, prefix): yield m - def get_resource_reader(self, fullname): - try: - if not self.is_package(fullname): - return None - except ImportError: - return None - return _ResfsResourceReader(self, fullname) - - -class _ResfsResourceReader: - - def __init__(self, importer, fullname): - self.importer = importer - self.fullname = fullname - - import os - self.prefix = "{}/".format(os.path.dirname(self.importer.get_filename(self.fullname))) - - def open_resource(self, resource): - path = f'{self.prefix}{resource}' - from io import BytesIO - try: - return BytesIO(self.importer.get_data(path)) - except OSError: - raise FileNotFoundError(path) - - def resource_path(self, resource): - # All resources are in the binary file, so there is no path to the file. - # Raising FileNotFoundError tells the higher level API to extract the - # binary data and create a temporary file. - raise FileNotFoundError - - def is_resource(self, name): - path = f'{self.prefix}{name}' - try: - self.importer.get_data(path) - except OSError: - return False - return True - - def contents(self): - subdirs_seen = set() - for key in resfs_files(self.prefix): - relative = key[len(self.prefix):] - res_or_subdir, *other = relative.split(b'/') - if not other: - yield _s(res_or_subdir) - elif res_or_subdir not in subdirs_seen: - subdirs_seen.add(res_or_subdir) - yield _s(res_or_subdir) - - + def get_resource_reader(self, fullname): + try: + if not self.is_package(fullname): + return None + except ImportError: + return None + return _ResfsResourceReader(self, fullname) + + +class _ResfsResourceReader: + + def __init__(self, importer, fullname): + self.importer = importer + self.fullname = fullname + + import os + self.prefix = "{}/".format(os.path.dirname(self.importer.get_filename(self.fullname))) + + def open_resource(self, resource): + path = f'{self.prefix}{resource}' + from io import BytesIO + try: + return BytesIO(self.importer.get_data(path)) + except OSError: + raise FileNotFoundError(path) + + def resource_path(self, resource): + # All resources are in the binary file, so there is no path to the file. + # Raising FileNotFoundError tells the higher level API to extract the + # binary data and create a temporary file. + raise FileNotFoundError + + def is_resource(self, name): + path = f'{self.prefix}{name}' + try: + self.importer.get_data(path) + except OSError: + return False + return True + + def contents(self): + subdirs_seen = set() + for key in resfs_files(self.prefix): + relative = key[len(self.prefix):] + res_or_subdir, *other = relative.split(b'/') + if not other: + yield _s(res_or_subdir) + elif res_or_subdir not in subdirs_seen: + subdirs_seen.add(res_or_subdir) + yield _s(res_or_subdir) + + class BuiltinSubmoduleImporter(BuiltinImporter): @classmethod def find_spec(cls, fullname, path=None, target=None): diff --git a/library/python/runtime_py3/main/main.c b/library/python/runtime_py3/main/main.c index 939c290827..3159800615 100644 --- a/library/python/runtime_py3/main/main.c +++ b/library/python/runtime_py3/main/main.c @@ -1,5 +1,5 @@ #include <Python.h> -#include <contrib/tools/python3/src/Include/internal/pycore_runtime.h> // _PyRuntime_Initialize() +#include <contrib/tools/python3/src/Include/internal/pycore_runtime.h> // _PyRuntime_Initialize() #include <stdlib.h> #include <string.h> @@ -9,7 +9,7 @@ void Py_InitArgcArgv(int argc, wchar_t **argv); char* GetPyMain(); static const char* env_entry_point = "Y_PYTHON_ENTRY_POINT"; -static const char* env_bytes_warning = "Y_PYTHON_BYTES_WARNING"; +static const char* env_bytes_warning = "Y_PYTHON_BYTES_WARNING"; #ifdef _MSC_VER extern char** environ; @@ -74,11 +74,11 @@ static int RunModule(const char *modname) } static int pymain(int argc, char** argv) { - PyStatus status = _PyRuntime_Initialize(); - if (PyStatus_Exception(status)) { - Py_ExitStatusException(status); - } - + PyStatus status = _PyRuntime_Initialize(); + if (PyStatus_Exception(status)) { + Py_ExitStatusException(status); + } + int i, sts = 1; char* oldloc = NULL; wchar_t** argv_copy = NULL; @@ -95,15 +95,15 @@ static int pymain(int argc, char** argv) { } } - PyConfig config; - PyConfig_InitPythonConfig(&config); - config.pathconfig_warnings = 0; /* Suppress errors from getpath.c */ - - const char* bytes_warning = getenv(env_bytes_warning); - if (bytes_warning) { - config.bytes_warning = atoi(bytes_warning); - } - + PyConfig config; + PyConfig_InitPythonConfig(&config); + config.pathconfig_warnings = 0; /* Suppress errors from getpath.c */ + + const char* bytes_warning = getenv(env_bytes_warning); + if (bytes_warning) { + config.bytes_warning = atoi(bytes_warning); + } + oldloc = _PyMem_RawStrdup(setlocale(LC_ALL, NULL)); if (!oldloc) { fprintf(stderr, "out of memory\n"); @@ -116,7 +116,7 @@ static int pymain(int argc, char** argv) { argv_copy2[i] = argv_copy[i]; if (!argv_copy[i]) { fprintf(stderr, "Unable to decode the command line argument #%i\n", - i + 1); + i + 1); argc = i; goto error; } @@ -125,15 +125,15 @@ static int pymain(int argc, char** argv) { PyMem_RawFree(oldloc); oldloc = NULL; - if (argc >= 1) - Py_SetProgramName(argv_copy[0]); - - status = Py_InitializeFromConfig(&config); - PyConfig_Clear(&config); - if (PyStatus_Exception(status)) { - Py_ExitStatusException(status); - } - + if (argc >= 1) + Py_SetProgramName(argv_copy[0]); + + status = Py_InitializeFromConfig(&config); + PyConfig_Clear(&config); + if (PyStatus_Exception(status)) { + Py_ExitStatusException(status); + } + const char* entry_point = getenv(env_entry_point); if (entry_point) { entry_point_copy = strdup(entry_point); diff --git a/library/python/runtime_py3/main/ya.make b/library/python/runtime_py3/main/ya.make index 30a96c8728..f308a93b28 100644 --- a/library/python/runtime_py3/main/ya.make +++ b/library/python/runtime_py3/main/ya.make @@ -14,10 +14,10 @@ ADDINCL( contrib/tools/python3/src/Include ) -CFLAGS( - -DPy_BUILD_CORE -) - +CFLAGS( + -DPy_BUILD_CORE +) + SRCS( main.c get_py_main.cpp diff --git a/library/python/runtime_py3/sitecustomize.pyx b/library/python/runtime_py3/sitecustomize.pyx index 0273d059de..966bbe8ba6 100644 --- a/library/python/runtime_py3/sitecustomize.pyx +++ b/library/python/runtime_py3/sitecustomize.pyx @@ -1,69 +1,69 @@ -import re -import sys - -import __res - -from importlib.abc import ResourceReader -from importlib.metadata import Distribution, DistributionFinder, PackageNotFoundError, Prepared - -ResourceReader.register(__res._ResfsResourceReader) - -METADATA_NAME = re.compile('^Name: (.*)$', re.MULTILINE) - - -class ArcadiaDistribution(Distribution): - - def __init__(self, prefix): - self.prefix = prefix - - def read_text(self, filename): - data = __res.resfs_read(f'{self.prefix}{filename}') - if data: - return data.decode('utf-8') - read_text.__doc__ = Distribution.read_text.__doc__ - - def locate_file(self, path): - return f'{self.prefix}{path}' - - -class ArcadiaMetadataFinder(DistributionFinder): - - prefixes = {} - - @classmethod - def find_distributions(cls, context=DistributionFinder.Context()): - found = cls._search_prefixes(context.name) - return map(ArcadiaDistribution, found) - - @classmethod - def _init_prefixes(cls): - cls.prefixes.clear() - - for resource in __res.resfs_files(): - resource = resource.decode('utf-8') - if not resource.endswith('METADATA'): - continue - data = __res.resfs_read(resource).decode('utf-8') - metadata_name = METADATA_NAME.search(data) - if metadata_name: - metadata_name = Prepared(metadata_name.group(1)) - cls.prefixes[metadata_name.normalized] = resource[:-len('METADATA')] - - @classmethod - def _search_prefixes(cls, name): - if not cls.prefixes: - cls._init_prefixes() - - if name: - try: - yield cls.prefixes[Prepared(name).normalized] - except KeyError: - raise PackageNotFoundError(name) - else: - for prefix in sorted(cls.prefixes.values()): - yield prefix - - -# monkeypatch standart library -import importlib.metadata -importlib.metadata.MetadataPathFinder = ArcadiaMetadataFinder +import re +import sys + +import __res + +from importlib.abc import ResourceReader +from importlib.metadata import Distribution, DistributionFinder, PackageNotFoundError, Prepared + +ResourceReader.register(__res._ResfsResourceReader) + +METADATA_NAME = re.compile('^Name: (.*)$', re.MULTILINE) + + +class ArcadiaDistribution(Distribution): + + def __init__(self, prefix): + self.prefix = prefix + + def read_text(self, filename): + data = __res.resfs_read(f'{self.prefix}{filename}') + if data: + return data.decode('utf-8') + read_text.__doc__ = Distribution.read_text.__doc__ + + def locate_file(self, path): + return f'{self.prefix}{path}' + + +class ArcadiaMetadataFinder(DistributionFinder): + + prefixes = {} + + @classmethod + def find_distributions(cls, context=DistributionFinder.Context()): + found = cls._search_prefixes(context.name) + return map(ArcadiaDistribution, found) + + @classmethod + def _init_prefixes(cls): + cls.prefixes.clear() + + for resource in __res.resfs_files(): + resource = resource.decode('utf-8') + if not resource.endswith('METADATA'): + continue + data = __res.resfs_read(resource).decode('utf-8') + metadata_name = METADATA_NAME.search(data) + if metadata_name: + metadata_name = Prepared(metadata_name.group(1)) + cls.prefixes[metadata_name.normalized] = resource[:-len('METADATA')] + + @classmethod + def _search_prefixes(cls, name): + if not cls.prefixes: + cls._init_prefixes() + + if name: + try: + yield cls.prefixes[Prepared(name).normalized] + except KeyError: + raise PackageNotFoundError(name) + else: + for prefix in sorted(cls.prefixes.values()): + yield prefix + + +# monkeypatch standart library +import importlib.metadata +importlib.metadata.MetadataPathFinder = ArcadiaMetadataFinder diff --git a/library/python/runtime_py3/test/.dist-info/METADATA b/library/python/runtime_py3/test/.dist-info/METADATA index a2af7dff1a..bb36162199 100644 --- a/library/python/runtime_py3/test/.dist-info/METADATA +++ b/library/python/runtime_py3/test/.dist-info/METADATA @@ -1,14 +1,14 @@ -Metadata-Version: 2.1 -Name: foo-bar -Version: 1.2.3 -Summary: -Home-page: https://foo.org/ -Author: Foo -Author-email: foo@ya.com -License: UNKNOWN -Platform: any -Classifier: Development Status :: 4 - Beta -Classifier: Programming Language :: Python :: 3 -Requires-Python: >=3.8 -Requires-Dist: Werkzeug (>=0.15) -Requires-Dist: Jinja2 (>=2.10.1) +Metadata-Version: 2.1 +Name: foo-bar +Version: 1.2.3 +Summary: +Home-page: https://foo.org/ +Author: Foo +Author-email: foo@ya.com +License: UNKNOWN +Platform: any +Classifier: Development Status :: 4 - Beta +Classifier: Programming Language :: Python :: 3 +Requires-Python: >=3.8 +Requires-Dist: Werkzeug (>=0.15) +Requires-Dist: Jinja2 (>=2.10.1) diff --git a/library/python/runtime_py3/test/.dist-info/RECORD b/library/python/runtime_py3/test/.dist-info/RECORD index 4199b6bece..dabbbff80d 100644 --- a/library/python/runtime_py3/test/.dist-info/RECORD +++ b/library/python/runtime_py3/test/.dist-info/RECORD @@ -1 +1 @@ -foo_bar.py,sha256=0000000000000000000000000000000000000000000,20 +foo_bar.py,sha256=0000000000000000000000000000000000000000000,20 diff --git a/library/python/runtime_py3/test/.dist-info/entry_points.txt b/library/python/runtime_py3/test/.dist-info/entry_points.txt index 525429d658..f5e2fd2657 100644 --- a/library/python/runtime_py3/test/.dist-info/entry_points.txt +++ b/library/python/runtime_py3/test/.dist-info/entry_points.txt @@ -1,2 +1,2 @@ -[console_scripts] -foo_cli = foo_bar:cli +[console_scripts] +foo_cli = foo_bar:cli diff --git a/library/python/runtime_py3/test/.dist-info/top_level.txt b/library/python/runtime_py3/test/.dist-info/top_level.txt index 8009c4b1f1..d2c068bc6b 100644 --- a/library/python/runtime_py3/test/.dist-info/top_level.txt +++ b/library/python/runtime_py3/test/.dist-info/top_level.txt @@ -1 +1 @@ -foo_bar +foo_bar diff --git a/library/python/runtime_py3/test/resources/foo.txt b/library/python/runtime_py3/test/resources/foo.txt index 59ea98c2c6..ba0e162e1c 100644 --- a/library/python/runtime_py3/test/resources/foo.txt +++ b/library/python/runtime_py3/test/resources/foo.txt @@ -1 +1 @@ -bar
\ No newline at end of file +bar
\ No newline at end of file diff --git a/library/python/runtime_py3/test/resources/submodule/bar.txt b/library/python/runtime_py3/test/resources/submodule/bar.txt index 356e2c858c..1910281566 100644 --- a/library/python/runtime_py3/test/resources/submodule/bar.txt +++ b/library/python/runtime_py3/test/resources/submodule/bar.txt @@ -1 +1 @@ -foo
\ No newline at end of file +foo
\ No newline at end of file diff --git a/library/python/runtime_py3/test/test_metadata.py b/library/python/runtime_py3/test/test_metadata.py index 7e7d9f0c1c..686c176468 100644 --- a/library/python/runtime_py3/test/test_metadata.py +++ b/library/python/runtime_py3/test/test_metadata.py @@ -1,44 +1,44 @@ -import importlib.metadata as im - -import pytest - - -@pytest.mark.parametrize("name", ("foo-bar", "foo_bar", "Foo-Bar")) -def test_distribution(name): - assert im.distribution(name) is not None - - -def test_unknown_package(): - with pytest.raises(im.PackageNotFoundError): - im.distribution("bar") - - -def test_version(): - assert im.version("foo-bar") == "1.2.3" - - -def test_metadata(): - assert im.metadata("foo-bar") is not None - - -def test_files(): - files = im.files("foo-bar") - assert len(files) == 1 - assert files[0].name == "foo_bar.py" - assert files[0].size == 20 - - -def test_requires(): - assert im.requires("foo-bar") == ["Werkzeug (>=0.15)", "Jinja2 (>=2.10.1)"] - - -def test_entry_points(): - entry_points = im.entry_points() - assert "console_scripts" in entry_points - - flg_found = False - for entry_point in entry_points["console_scripts"]: - if entry_point.name == "foo_cli" and entry_point.value == "foo_bar:cli": - flg_found = True - - assert flg_found +import importlib.metadata as im + +import pytest + + +@pytest.mark.parametrize("name", ("foo-bar", "foo_bar", "Foo-Bar")) +def test_distribution(name): + assert im.distribution(name) is not None + + +def test_unknown_package(): + with pytest.raises(im.PackageNotFoundError): + im.distribution("bar") + + +def test_version(): + assert im.version("foo-bar") == "1.2.3" + + +def test_metadata(): + assert im.metadata("foo-bar") is not None + + +def test_files(): + files = im.files("foo-bar") + assert len(files) == 1 + assert files[0].name == "foo_bar.py" + assert files[0].size == 20 + + +def test_requires(): + assert im.requires("foo-bar") == ["Werkzeug (>=0.15)", "Jinja2 (>=2.10.1)"] + + +def test_entry_points(): + entry_points = im.entry_points() + assert "console_scripts" in entry_points + + flg_found = False + for entry_point in entry_points["console_scripts"]: + if entry_point.name == "foo_cli" and entry_point.value == "foo_bar:cli": + flg_found = True + + assert flg_found diff --git a/library/python/runtime_py3/test/test_resources.py b/library/python/runtime_py3/test/test_resources.py index 8eb05380a5..a269329f42 100644 --- a/library/python/runtime_py3/test/test_resources.py +++ b/library/python/runtime_py3/test/test_resources.py @@ -1,60 +1,60 @@ -# -*- coding: utf-8 -*- - -import importlib.resources as ir - -import pytest - - -@pytest.mark.parametrize("package, resource", ( - ("resources", "foo.txt"), - ("resources.submodule", "bar.txt") -)) -def test_is_resource_good_path(package, resource): - assert ir.is_resource(package, resource) - - -@pytest.mark.parametrize("package, resource", ( - ("resources", "111.txt"), - ("resources.submodule", "222.txt") -)) -def test_is_resource_missing(package, resource): - assert not ir.is_resource(package, resource) - - -def test_is_resource_subresource_directory(): - # Directories are not resources. - assert not ir.is_resource("resources", "submodule") - - -@pytest.mark.parametrize("package, resource, expected", ( - ("resources", "foo.txt", b"bar"), - ("resources.submodule", "bar.txt", b"foo") -)) -def test_read_binary_good_path(package, resource, expected): - assert ir.read_binary(package, resource) == expected - - -def test_read_binary_missing(): - with pytest.raises(FileNotFoundError): - ir.read_binary("resources", "111.txt") - - -@pytest.mark.parametrize("package, resource, expected", ( - ("resources", "foo.txt", "bar"), - ("resources.submodule", "bar.txt", "foo") -)) -def test_read_text_good_path(package, resource, expected): - assert ir.read_text(package, resource) == expected - - -def test_read_text_missing(): - with pytest.raises(FileNotFoundError): - ir.read_text("resources", "111.txt") - - -@pytest.mark.parametrize("package, expected", ( - ("resources", ["submodule", "foo.txt"]), - ("resources.submodule", ["bar.txt"]) -)) -def test_contents_good_path(package, expected): - assert sorted(ir.contents(package)) == sorted(expected) +# -*- coding: utf-8 -*- + +import importlib.resources as ir + +import pytest + + +@pytest.mark.parametrize("package, resource", ( + ("resources", "foo.txt"), + ("resources.submodule", "bar.txt") +)) +def test_is_resource_good_path(package, resource): + assert ir.is_resource(package, resource) + + +@pytest.mark.parametrize("package, resource", ( + ("resources", "111.txt"), + ("resources.submodule", "222.txt") +)) +def test_is_resource_missing(package, resource): + assert not ir.is_resource(package, resource) + + +def test_is_resource_subresource_directory(): + # Directories are not resources. + assert not ir.is_resource("resources", "submodule") + + +@pytest.mark.parametrize("package, resource, expected", ( + ("resources", "foo.txt", b"bar"), + ("resources.submodule", "bar.txt", b"foo") +)) +def test_read_binary_good_path(package, resource, expected): + assert ir.read_binary(package, resource) == expected + + +def test_read_binary_missing(): + with pytest.raises(FileNotFoundError): + ir.read_binary("resources", "111.txt") + + +@pytest.mark.parametrize("package, resource, expected", ( + ("resources", "foo.txt", "bar"), + ("resources.submodule", "bar.txt", "foo") +)) +def test_read_text_good_path(package, resource, expected): + assert ir.read_text(package, resource) == expected + + +def test_read_text_missing(): + with pytest.raises(FileNotFoundError): + ir.read_text("resources", "111.txt") + + +@pytest.mark.parametrize("package, expected", ( + ("resources", ["submodule", "foo.txt"]), + ("resources.submodule", ["bar.txt"]) +)) +def test_contents_good_path(package, expected): + assert sorted(ir.contents(package)) == sorted(expected) diff --git a/library/python/runtime_py3/test/ya.make b/library/python/runtime_py3/test/ya.make index 9056e48a39..4ec3db74f5 100644 --- a/library/python/runtime_py3/test/ya.make +++ b/library/python/runtime_py3/test/ya.make @@ -12,29 +12,29 @@ PEERDIR( contrib/python/PyYAML ) -PY_SRCS( - TOP_LEVEL - resources/__init__.py - resources/submodule/__init__.py -) - -TEST_SRCS( - test_metadata.py - test_resources.py - test_traceback.py +PY_SRCS( + TOP_LEVEL + resources/__init__.py + resources/submodule/__init__.py +) + +TEST_SRCS( + test_metadata.py + test_resources.py + test_traceback.py test_arcadia_source_finder.py -) - -RESOURCE_FILES( - PREFIX library/python/runtime_py3/test/ - .dist-info/METADATA - .dist-info/RECORD - .dist-info/entry_points.txt - .dist-info/top_level.txt - resources/foo.txt - resources/submodule/bar.txt -) - +) + +RESOURCE_FILES( + PREFIX library/python/runtime_py3/test/ + .dist-info/METADATA + .dist-info/RECORD + .dist-info/entry_points.txt + .dist-info/top_level.txt + resources/foo.txt + resources/submodule/bar.txt +) + END() RECURSE_FOR_TESTS(traceback) diff --git a/library/python/runtime_py3/ya.make b/library/python/runtime_py3/ya.make index dc4dbd2b10..fa5c11341a 100644 --- a/library/python/runtime_py3/ya.make +++ b/library/python/runtime_py3/ya.make @@ -23,12 +23,12 @@ ENABLE(PYBUILD_NO_PYC) PY_SRCS( entry_points.py TOP_LEVEL - - CYTHON_DIRECTIVE - language_level=3 - + + CYTHON_DIRECTIVE + language_level=3 + __res.pyx - sitecustomize.pyx + sitecustomize.pyx ) IF (CYTHON_COVERAGE) diff --git a/library/python/symbols/ya.make b/library/python/symbols/ya.make index c19c49ac88..340a710c48 100644 --- a/library/python/symbols/ya.make +++ b/library/python/symbols/ya.make @@ -8,5 +8,5 @@ RECURSE( libmagic python uuid - win_unicode_console + win_unicode_console ) diff --git a/library/python/testing/import_test/import_test.py b/library/python/testing/import_test/import_test.py index 5dd0c49306..3e3b7234ef 100644 --- a/library/python/testing/import_test/import_test.py +++ b/library/python/testing/import_test/import_test.py @@ -101,16 +101,16 @@ def main(): skip_names = sys.argv[1:] os.environ['Y_PYTHON_IMPORT_TEST'] = '' - - # We should initialize Django before importing any applications - if os.getenv('DJANGO_SETTINGS_MODULE'): + + # We should initialize Django before importing any applications + if os.getenv('DJANGO_SETTINGS_MODULE'): try: import django except ImportError: pass else: django.setup() - + py_main = __res.find('PY_MAIN') if py_main: diff --git a/library/python/testing/yatest_common/yatest/common/process.py b/library/python/testing/yatest_common/yatest/common/process.py index 0c2dbb08a0..a8bcc21f51 100644 --- a/library/python/testing/yatest_common/yatest/common/process.py +++ b/library/python/testing/yatest_common/yatest/common/process.py @@ -544,8 +544,8 @@ def _get_command_output_file(cmd, ext): try: # if execution is performed from test, save out / err to the test logs dir import yatest.common - import library.python.pytest.plugins.ya - if getattr(library.python.pytest.plugins.ya, 'pytest_config', None) is None: + import library.python.pytest.plugins.ya + if getattr(library.python.pytest.plugins.ya, 'pytest_config', None) is None: raise ImportError("not in test") filename = path.get_unique_file_path(yatest.common.output_path(), filename) yatest_logger.debug("Command %s will be placed to %s", ext, os.path.basename(filename)) diff --git a/library/python/testing/yatest_common/yatest/common/runtime.py b/library/python/testing/yatest_common/yatest/common/runtime.py index e40be347df..e55e193446 100644 --- a/library/python/testing/yatest_common/yatest/common/runtime.py +++ b/library/python/testing/yatest_common/yatest/common/runtime.py @@ -12,9 +12,9 @@ _lock = threading.Lock() def _get_ya_config(): try: - import library.python.pytest.plugins.ya as ya_plugin - if ya_plugin.pytest_config is not None: - return ya_plugin.pytest_config + import library.python.pytest.plugins.ya as ya_plugin + if ya_plugin.pytest_config is not None: + return ya_plugin.pytest_config import pytest return pytest.config except (ImportError, AttributeError): diff --git a/library/python/testing/yatest_lib/ya.py b/library/python/testing/yatest_lib/ya.py index 9b077f5ace..c13b58a19f 100644 --- a/library/python/testing/yatest_lib/ya.py +++ b/library/python/testing/yatest_lib/ya.py @@ -218,22 +218,22 @@ class Ya(object): assert self._test_item_node_id return self._test_item_node_id - @property - def pytest_config(self): - if not hasattr(self, "_pytest_config"): - import library.python.pytest.plugins.ya as ya_plugin - self._pytest_config = ya_plugin.pytest_config - return self._pytest_config - + @property + def pytest_config(self): + if not hasattr(self, "_pytest_config"): + import library.python.pytest.plugins.ya as ya_plugin + self._pytest_config = ya_plugin.pytest_config + return self._pytest_config + def set_metric_value(self, name, val): node_id = self.get_test_item_node_id() - if node_id not in self.pytest_config.test_metrics: - self.pytest_config.test_metrics[node_id] = {} + if node_id not in self.pytest_config.test_metrics: + self.pytest_config.test_metrics[node_id] = {} - self.pytest_config.test_metrics[node_id][name] = val + self.pytest_config.test_metrics[node_id][name] = val def get_metric_value(self, name, default=None): - res = self.pytest_config.test_metrics.get(self.get_test_item_node_id(), {}).get(name) + res = self.pytest_config.test_metrics.get(self.get_test_item_node_id(), {}).get(name) if res is None: return default return res diff --git a/library/python/ya.make b/library/python/ya.make index abdb3721e5..2e1eb6e0e1 100644 --- a/library/python/ya.make +++ b/library/python/ya.make @@ -141,7 +141,7 @@ RECURSE( pymain pyscopg2 pytest - pytest-mongodb + pytest-mongodb pytest/allure pytest/empty pytest/plugins @@ -164,7 +164,7 @@ RECURSE( runtime_py3/test runtime_test sanitizers - sdms_api + sdms_api sfx selenium_ui_test sendmsg |