diff options
author | anastasy888 <anastasy888@yandex-team.ru> | 2022-02-10 16:45:54 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:54 +0300 |
commit | 49f765d71da452ea93138a25559dfa68dd76c7f3 (patch) | |
tree | 1016041feb637349e401dcc0fa85217dd2c2c639 /library/python/pytest/plugins | |
parent | 7353a3fdea9c67c256980c00a2b3b67f09b23a27 (diff) | |
download | ydb-49f765d71da452ea93138a25559dfa68dd76c7f3.tar.gz |
Restoring authorship annotation for <anastasy888@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/python/pytest/plugins')
-rw-r--r-- | library/python/pytest/plugins/ya.py | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/library/python/pytest/plugins/ya.py b/library/python/pytest/plugins/ya.py index 1bde03042d..9e08450847 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 |