@@ -63,15 +63,17 @@ def pytest_runtest_logreport(self, report):
63
63
if report .passed and report .when != "call" :
64
64
return
65
65
66
- # do not update tests that have already failed
66
+ # Update tests that have already failed with capstdout and return.
67
67
if not state .is_passing ():
68
+ if report .capstdout .rstrip ('FFFFFFFF ' ):
69
+ state .output = report .capstdout .rstrip ('FFFFFFFF ' )
68
70
return
69
71
70
- # captured relevant stdout content, if any
72
+ # Record captured relevant stdout content for passed tests.
71
73
if report .capstdout :
72
74
state .output = report .capstdout
73
75
74
- # handle test failure
76
+ # Handle details of test failure
75
77
if report .failed :
76
78
77
79
# traceback that caused the issued, if any
@@ -91,19 +93,22 @@ def pytest_runtest_logreport(self, report):
91
93
source = Path (self .config .rootdir ) / report .fspath
92
94
state .test_code = TestOrder .function_source (test_id , source )
93
95
96
+
94
97
# Looks up test_ids from parent when the test is a subtest.
95
98
if state .task_id == 0 and 'variation' in state .name :
96
99
parent_test_name = state .name .split (' ' )[0 ]
97
100
parent_task_id = self .tests [parent_test_name ].task_id
98
101
state .task_id = parent_task_id
99
102
103
+
100
104
# Changes status of parent to fail if any of the subtests fail.
101
105
if state .fail :
102
106
self .tests [parent_test_name ].fail (
103
107
message = "One or more variations of this test failed. Details can be found under each [variant#]."
104
108
)
105
109
self .tests [parent_test_name ].test_code = state .test_code
106
110
111
+
107
112
def pytest_sessionfinish (self , session , exitstatus ):
108
113
"""
109
114
Processes the results into a report.
@@ -141,7 +146,7 @@ def pytest_exception_interact(self, node, call, report):
141
146
err = excinfo .getrepr (style = "no" , abspath = False )
142
147
143
148
# trim off full traceback for first exercise to be friendlier and clearer
144
- if 'lasagna_test.py ' in str (err .chain [0 ]):
149
+ if 'Lasagna' in node . name and 'ImportError ' in str (err .chain [0 ]):
145
150
trace = err .chain [- 2 ][0 ]
146
151
else :
147
152
trace = err .chain [- 1 ][0 ]
0 commit comments