diff options
| author | anastasy888 <[email protected]> | 2022-02-10 16:45:54 +0300 | 
|---|---|---|
| committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:45:54 +0300 | 
| commit | 49f765d71da452ea93138a25559dfa68dd76c7f3 (patch) | |
| tree | 1016041feb637349e401dcc0fa85217dd2c2c639 /library/python | |
| parent | 7353a3fdea9c67c256980c00a2b3b67f09b23a27 (diff) | |
Restoring authorship annotation for <[email protected]>. Commit 1 of 2.
Diffstat (limited to 'library/python')
| -rw-r--r-- | library/python/pytest/plugins/ya.py | 62 | ||||
| -rw-r--r-- | library/python/testing/import_test/import_test.py | 30 | ||||
| -rw-r--r-- | library/python/testing/yatest_common/yatest/common/canonical.py | 14 | 
3 files changed, 53 insertions, 53 deletions
| diff --git a/library/python/pytest/plugins/ya.py b/library/python/pytest/plugins/ya.py index 1bde03042d4..9e084508473 100644 --- a/library/python/pytest/plugins/ya.py +++ b/library/python/pytest/plugins/ya.py @@ -568,7 +568,7 @@ def pytest_runtest_makereport(item, call):              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) -            else: +            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) @@ -753,8 +753,8 @@ class TraceReportGenerator(object):          self._filename = out_file_path          self._file = open(out_file_path, 'w')          self._wreckage_filename = out_file_path + '.wreckage' -        self._test_messages = {} -        self._test_duration = {} +        self._test_messages = {}  +        self._test_duration = {}           # Some machinery to avoid data corruption due sloppy fork()          self._current_test = (None, None)          self._pid = os.getpid() @@ -826,7 +826,7 @@ class TraceReportGenerator(object):          self._current_test = (class_name, subtest_name)          self.trace('subtest-started', message) -    def on_finish_test_case(self, test_item, duration_only=False): +    def on_finish_test_case(self, test_item, duration_only=False):           if test_item.result is not None:              try:                  result = canon.serialize(test_item.result) @@ -837,29 +837,29 @@ class TraceReportGenerator(object):                  result = None          else:              result = None - -        if duration_only and test_item.nodeid in self._test_messages:  # add teardown time -            message = self._test_messages[test_item.nodeid] -        else: -            comment = self._test_messages[test_item.nodeid]['comment'] if test_item.nodeid in self._test_messages else '' -            comment += self._get_comment(test_item) -            message = { -                'class': yatest_lib.tools.to_utf8(test_item.class_name), -                'subtest': yatest_lib.tools.to_utf8(test_item.test_name), -                'status': test_item.status, -                'comment': comment, -                'result': result, +  +        if duration_only and test_item.nodeid in self._test_messages:  # add teardown time  +            message = self._test_messages[test_item.nodeid]  +        else:  +            comment = self._test_messages[test_item.nodeid]['comment'] if test_item.nodeid in self._test_messages else ''  +            comment += self._get_comment(test_item)  +            message = {  +                'class': yatest_lib.tools.to_utf8(test_item.class_name),  +                'subtest': yatest_lib.tools.to_utf8(test_item.test_name),  +                'status': test_item.status,  +                'comment': comment,  +                'result': result,                   'metrics': pytest_config.test_metrics.get(test_item.nodeid), -                'is_diff_test': 'diff_test' in test_item.keywords, -                'tags': _get_item_tags(test_item), -            } +                '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] - -        message['time'] = self._test_duration.get(test_item.nodeid, test_item.duration) - +  +        message['time'] = self._test_duration.get(test_item.nodeid, test_item.duration)  +           self.trace('subtest-finished', message) -        self._test_messages[test_item.nodeid] = message +        self._test_messages[test_item.nodeid] = message       def dump_suite_metrics(self):          message = {"metrics": pytest_config.suite_metrics} @@ -868,12 +868,12 @@ class TraceReportGenerator(object):      def on_error(self, test_item):          self.trace('chunk_event', {"errors": [(test_item.status, self._get_comment(test_item))]}) -    def on_log_report(self, test_item): -        if test_item.nodeid in self._test_duration: -            self._test_duration[test_item.nodeid] += test_item._duration -        else: -            self._test_duration[test_item.nodeid] = test_item._duration - +    def on_log_report(self, test_item):  +        if test_item.nodeid in self._test_duration:  +            self._test_duration[test_item.nodeid] += test_item._duration  +        else:  +            self._test_duration[test_item.nodeid] = test_item._duration  +       @staticmethod      def _get_comment(test_item):          msg = yatest_lib.tools.to_utf8(test_item.error) @@ -956,8 +956,8 @@ class DryTraceReportGenerator(TraceReportGenerator):      """      def __init__(self, *args, **kwargs): -        self._test_messages = {} -        self._test_duration = {} +        self._test_messages = {}  +        self._test_duration = {}       def trace(self, name, value):          pass diff --git a/library/python/testing/import_test/import_test.py b/library/python/testing/import_test/import_test.py index 3e3b7234ef1..f821aa3cdab 100644 --- a/library/python/testing/import_test/import_test.py +++ b/library/python/testing/import_test/import_test.py @@ -51,12 +51,12 @@ def check_imports(no_check=(), extra=(), skip_func=None, py_main=None):              print('SKIP', module, '''without "if __name__ == '__main__'" check''')              continue -        def print_backtrace_marked(e): -            tb_exc = traceback.format_exception(*e) -            for item in tb_exc: -                for l in item.splitlines(): -                    print('FAIL:', l, file=sys.stderr) - +        def print_backtrace_marked(e):  +            tb_exc = traceback.format_exception(*e)  +            for item in tb_exc:  +                for l in item.splitlines():  +                    print('FAIL:', l, file=sys.stderr)  +           try:              print('TRY', module)              # XXX waiting for py3 to use print(..., flush=True) @@ -75,17 +75,17 @@ def check_imports(no_check=(), extra=(), skip_func=None, py_main=None):              print('OK ', module, '{:.3f}s'.format(delay))          except Exception as e: -            print('FAIL:', module, e, file=sys.stderr) -            print_backtrace_marked(sys.exc_info()) -            failed.append('{}: {}'.format(module, e)) - -        except: -            e = sys.exc_info() -            print('FAIL:', module, e, file=sys.stderr) -            print_backtrace_marked(e) +            print('FAIL:', module, e, file=sys.stderr)  +            print_backtrace_marked(sys.exc_info())               failed.append('{}: {}'.format(module, e)) -            raise +        except:  +            e = sys.exc_info()  +            print('FAIL:', module, e, file=sys.stderr)  +            print_backtrace_marked(e)  +            failed.append('{}: {}'.format(module, e))  +            raise  +       print("Slowest imports:")      for m, t in sorted(import_times.items(), key=lambda x: x[1], reverse=True)[:30]:          print('  ', '{:.3f}s'.format(t), m) diff --git a/library/python/testing/yatest_common/yatest/common/canonical.py b/library/python/testing/yatest_common/yatest/common/canonical.py index b6a136d3e9b..4fa3defa77b 100644 --- a/library/python/testing/yatest_common/yatest/common/canonical.py +++ b/library/python/testing/yatest_common/yatest/common/canonical.py @@ -37,13 +37,13 @@ def canonical_file(path, diff_tool=None, local=False, universal_lines=False, dif      safe_path = os.path.join(tempdir, os.path.basename(abs_path))      # if the created file is in output_path, we copy it, so that it will be available when the tests finishes      _copy(path, safe_path, universal_lines=universal_lines) -    if diff_tool: -        if not isinstance(diff_tool, six.string_types): -            try:  # check if iterable -                if not isinstance(diff_tool[0], six.string_types): -                    raise Exception("Invalid custom diff-tool: not cmd") -            except: -                raise Exception("Invalid custom diff-tool: not binary path") +    if diff_tool:  +        if not isinstance(diff_tool, six.string_types):  +            try:  # check if iterable  +                if not isinstance(diff_tool[0], six.string_types):  +                    raise Exception("Invalid custom diff-tool: not cmd")  +            except:  +                raise Exception("Invalid custom diff-tool: not binary path")       return runtime._get_ya_plugin_instance().file(safe_path, diff_tool=diff_tool, local=local, diff_file_name=diff_file_name, diff_tool_timeout=diff_tool_timeout) | 
