blob: 7c85d62112d9a56de19d5ce2c61050e89bcc6e3e [file] [log] [blame]
Hanna Arhipovae6ed8e42019-05-15 16:27:08 +03001from fixtures.base import *
2
3
4@pytest.hookimpl(tryfirst=True, hookwrapper=True)
5def pytest_runtest_makereport(item, call):
6 outcome = yield
7
8 rep = outcome.get_result()
9 setattr(item, "rep_" + rep.when, rep)
10 rep.description = "{}".format(str(item.function.__doc__))
11 setattr(item, 'description', item.function.__doc__)
12
13
14@pytest.fixture(autouse=True)
15def show_test_steps(request):
16 yield
17 # request.node is an "item" because we use the default
18 # "function" scope
19 if request.node.description is None or request.node.description == "None":
20 return
21 try:
22 if request.node.rep_setup.failed:
23 print("setup failed. The following steps were attempted: \n {steps}".format(steps=request.node.description))
24 elif request.node.rep_setup.passed:
25 if request.node.rep_call.failed:
26 print("test execution failed! The following steps were attempted: \n {steps}".format(steps=request.node.description))
27 except BaseException as e:
28 print("Error in show_test_steps fixture: {}".format(e))
29 pass