Add test steps into the stdout if test failed.
Related-Prod:#PROD-29995(PROD:29995)
Change-Id: Ie0a03d4d8896c7d7836cfd57736778f3896bcb87
diff --git a/test_set/cvp-sanity/conftest.py b/test_set/cvp-sanity/conftest.py
index 693d514..7c85d62 100644
--- a/test_set/cvp-sanity/conftest.py
+++ b/test_set/cvp-sanity/conftest.py
@@ -1 +1,29 @@
from fixtures.base import *
+
+
+@pytest.hookimpl(tryfirst=True, hookwrapper=True)
+def pytest_runtest_makereport(item, call):
+ outcome = yield
+
+ rep = outcome.get_result()
+ setattr(item, "rep_" + rep.when, rep)
+ rep.description = "{}".format(str(item.function.__doc__))
+ setattr(item, 'description', item.function.__doc__)
+
+
+@pytest.fixture(autouse=True)
+def show_test_steps(request):
+ yield
+ # request.node is an "item" because we use the default
+ # "function" scope
+ if request.node.description is None or request.node.description == "None":
+ return
+ try:
+ if request.node.rep_setup.failed:
+ print("setup failed. The following steps were attempted: \n {steps}".format(steps=request.node.description))
+ elif request.node.rep_setup.passed:
+ if request.node.rep_call.failed:
+ print("test execution failed! The following steps were attempted: \n {steps}".format(steps=request.node.description))
+ except BaseException as e:
+ print("Error in show_test_steps fixture: {}".format(e))
+ pass
diff --git a/test_set/cvp-sanity/pytest.ini b/test_set/cvp-sanity/pytest.ini
index 121300d..7d6dde9 100644
--- a/test_set/cvp-sanity/pytest.ini
+++ b/test_set/cvp-sanity/pytest.ini
@@ -1,3 +1,3 @@
[pytest]
norecursedirs = venv
-addopts = -vv
\ No newline at end of file
+addopts = -vv --tb=short
\ No newline at end of file