@@ -87,7 +87,7 @@ def pytest_exception_interact(node, call, report):
87
87
report_value = "error"
88
88
if call .excinfo .typename == "AssertionError" :
89
89
report_value = "failure"
90
- node_id = str (node .nodeid )
90
+ node_id = get_workspace_node_id ( str (node .nodeid ) )
91
91
if node_id not in collected_tests_so_far :
92
92
collected_tests_so_far .append (node_id )
93
93
item_result = create_test_outcome (
@@ -106,6 +106,14 @@ def pytest_exception_interact(node, call, report):
106
106
)
107
107
108
108
109
+ def get_workspace_node_id (testid : str ):
110
+ id = testid
111
+ global RELATIVE_INVOCATION_PATH
112
+ if RELATIVE_INVOCATION_PATH :
113
+ id = str (pathlib .Path (RELATIVE_INVOCATION_PATH ) / testid )
114
+ return id
115
+
116
+
109
117
def pytest_keyboard_interrupt (excinfo ):
110
118
"""A pytest hook that is called when a keyboard interrupt is raised.
111
119
@@ -130,15 +138,15 @@ class TestOutcome(Dict):
130
138
131
139
132
140
def create_test_outcome (
133
- test : str ,
141
+ testid : str ,
134
142
outcome : str ,
135
143
message : Union [str , None ],
136
144
traceback : Union [str , None ],
137
145
subtype : Optional [str ] = None ,
138
146
) -> TestOutcome :
139
147
"""A function that creates a TestOutcome object."""
140
148
return TestOutcome (
141
- test = test ,
149
+ test = testid ,
142
150
outcome = outcome ,
143
151
message = message ,
144
152
traceback = traceback , # TODO: traceback
@@ -193,7 +201,7 @@ def pytest_report_teststatus(report, config):
193
201
elif report .failed :
194
202
report_value = "failure"
195
203
message = report .longreprtext
196
- node_id = str (report .nodeid )
204
+ node_id = get_workspace_node_id ( str (report .nodeid ) )
197
205
if node_id not in collected_tests_so_far :
198
206
collected_tests_so_far .append (node_id )
199
207
item_result = create_test_outcome (
@@ -222,7 +230,7 @@ def pytest_report_teststatus(report, config):
222
230
def pytest_runtest_protocol (item , nextitem ):
223
231
skipped = check_skipped_wrapper (item )
224
232
if skipped :
225
- node_id = str (item .nodeid )
233
+ node_id = get_workspace_node_id ( str (item .nodeid ) )
226
234
report_value = "skipped"
227
235
cwd = pathlib .Path .cwd ()
228
236
if node_id not in collected_tests_so_far :
@@ -480,10 +488,7 @@ def create_test_node(
480
488
test_case_loc : str = (
481
489
str (test_case .location [1 ] + 1 ) if (test_case .location [1 ] is not None ) else ""
482
490
)
483
- id = test_case .nodeid
484
- global RELATIVE_INVOCATION_PATH
485
- if RELATIVE_INVOCATION_PATH :
486
- id = str (pathlib .Path (RELATIVE_INVOCATION_PATH ) / test_case .nodeid )
491
+ id = get_workspace_node_id (test_case .nodeid )
487
492
return {
488
493
"name" : test_case .name ,
489
494
"path" : get_node_path (test_case ),
0 commit comments