aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorprettyboy <prettyboy@yandex-team.com>2023-01-24 18:03:18 +0300
committerprettyboy <prettyboy@yandex-team.com>2023-01-24 18:03:18 +0300
commit5b5f7ef2fbbd0172a749c8921a1755494bd1da2c (patch)
tree9bd81ac096fffc86ce143a48e085fe5d4503faf4
parent28aab6f5de02cd995ca582898264443e2810dbf0 (diff)
downloadydb-5b5f7ef2fbbd0172a749c8921a1755494bd1da2c.tar.gz
[library/python/pytest/plugins/ya] Added xfaildiff marker
-rw-r--r--library/python/pytest/plugins/ya.py23
1 files changed, 17 insertions, 6 deletions
diff --git a/library/python/pytest/plugins/ya.py b/library/python/pytest/plugins/ya.py
index 0b3c8127e4..1a2f438118 100644
--- a/library/python/pytest/plugins/ya.py
+++ b/library/python/pytest/plugins/ya.py
@@ -292,6 +292,12 @@ def pytest_configure(config):
if hasattr(signal, "SIGUSR2"):
signal.signal(signal.SIGUSR2, _graceful_shutdown)
+ # register custom markers
+ config.addinivalue_line(
+ "markers", "xfaildiff: Allows to mark test which is expected to have a diff with canonical data"
+ )
+
+
session_should_exit = False
@@ -542,8 +548,8 @@ def pytest_pyfunc_call(pyfuncitem):
@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)
+ def logreport(report, result, call, markers):
+ test_item = TestItem(report, result, pytest_config.option.test_suffix, markers=markers)
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()
@@ -580,7 +586,7 @@ def pytest_runtest_makereport(item, call):
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)
+ logreport(rep, result, call, item.own_markers)
def pytest_make_parametrize_id(config, val, argname):
@@ -624,15 +630,17 @@ def colorize(longrepr):
class TestItem(object):
- def __init__(self, report, result, test_suffix):
+ def __init__(self, report, result, test_suffix, markers=None):
self._result = result
self.nodeid = report.nodeid
self._class_name, self._test_name = tools.split_node_id(self.nodeid, test_suffix)
self._error = ""
self._status = None
- self._process_report(report)
self._duration = hasattr(report, 'duration') and report.duration or 0
self._keywords = getattr(report, "keywords", {})
+ self._xfaildiff = any(m.name == 'xfaildiff' for m in (markers or []))
+
+ self._process_report(report)
def _process_report(self, report):
if report.longrepr:
@@ -654,7 +662,10 @@ class TestItem(object):
self._status = 'skipped'
self.set_error(yatest_lib.tools.to_utf8(report.longrepr[-1]))
elif report.passed:
- self._status = 'good'
+ if self._xfaildiff:
+ self._status = 'xfaildiff'
+ else:
+ self._status = 'good'
else:
self._status = 'fail'