summaryrefslogtreecommitdiffstats
path: root/library/python/pytest
diff options
context:
space:
mode:
authorrobot-piglet <[email protected]>2026-05-08 11:44:05 +0300
committerrobot-piglet <[email protected]>2026-05-08 12:22:37 +0300
commit3dc0583b433b5e984df6da4443de57722d0e1bf4 (patch)
treeaccfb602596b354e07332fdd6672177008cb49be /library/python/pytest
parente794b70754bca3a24c8ff09bbf4f216e7da45a97 (diff)
Intermediate changes
commit_hash:9b6bd8ea4bc3ae7df2576daf77c181b20f7cd869
Diffstat (limited to 'library/python/pytest')
-rw-r--r--library/python/pytest/plugins/ya.py18
1 files changed, 15 insertions, 3 deletions
diff --git a/library/python/pytest/plugins/ya.py b/library/python/pytest/plugins/ya.py
index bc29dd96305..a42a942c39f 100644
--- a/library/python/pytest/plugins/ya.py
+++ b/library/python/pytest/plugins/ya.py
@@ -57,6 +57,8 @@ import yatest_lib.ya
from library.python.pytest import context
+DEFAULT_COMMENT_LIMIT = 8 * 1024 # 8 Kb
+
console_logger = logging.getLogger("console")
yatest_logger = logging.getLogger("ya.test")
@@ -195,6 +197,16 @@ def pytest_addoption(parser):
parser.addoption("--pdb-on-sigusr1", action="store_true", default=False, help="setup pdb.set_trace on SIGUSR1")
parser.addoption("--test-tool-bin", help="Path to test_tool")
parser.addoption("--test-list-path", dest="test_list_path", action="store", help="path to test list", default="")
+ parser.addoption(
+ "--max-test-comment-size",
+ action="store",
+ dest="max_test_comment_size",
+ type=int,
+ default=DEFAULT_COMMENT_LIMIT,
+ help="Max length (in bytes) of a test result comment (assertion/diagnostic message) "
+ "written to the trace file. 0 (or any non-positive value) disables truncation. "
+ "Default is 8*1024 (8 Kb)",
+ )
def from_ya_test():
@@ -935,7 +947,7 @@ class TraceReportGenerator(object):
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)
+ comment += self._get_comment(test_item, pytest_config.option.max_test_comment_size)
message = {
'class': yatest_lib.tools.to_utf8(test_item.class_name),
'subtest': yatest_lib.tools.to_utf8(test_item.test_name),
@@ -962,7 +974,7 @@ class TraceReportGenerator(object):
self.trace("chunk_event", message)
def on_error(self, test_item):
- self.trace('chunk_event', {"errors": [(test_item.status, self._get_comment(test_item))]})
+ self.trace('chunk_event', {"errors": [(test_item.status, self._get_comment(test_item, pytest_config.option.max_test_comment_size))]})
def on_log_report(self, test_item):
if test_item.nodeid in self._test_duration:
@@ -971,7 +983,7 @@ class TraceReportGenerator(object):
self._test_duration[test_item.nodeid] = test_item._duration
@staticmethod
- def _get_comment(test_item, limit=8*1024):
+ def _get_comment(test_item, limit=DEFAULT_COMMENT_LIMIT):
msg = yatest_lib.tools.to_utf8(test_item.error)
if not msg:
return ""