@@ -264,11 +264,7 @@ def summary(
264264 )
265265 match = make_search_matcher (search_substring , search_regex )
266266 counts = _collect_counts (execution .suite , status_filters , match )
267- failures = (
268- _collect_failures (execution .suite , status_filters , full_paths = full_paths , match = match )
269- if show_failures
270- else None
271- )
267+ failures = _collect_failures (execution .suite , status_filters , match = match ) if show_failures else None
272268 exec_msg_counts = _count_execution_messages (getattr (execution , "errors" , None ))
273269 msg_counts = _count_all_messages (execution )
274270
@@ -419,7 +415,7 @@ def show(
419415 wanted = _normalise_statuses (status_filters )
420416 match = make_search_matcher (search_substring , search_regex )
421417 all_items = [
422- _make_test_item (t , message_chars = message_chars , full_paths = full_paths )
418+ _make_test_item (t , message_chars = message_chars )
423419 for t in _iter_all_tests (execution .suite )
424420 if (not wanted or t .status in wanted ) and (match is None or _raw_test_search_matches (t , match ))
425421 ]
@@ -635,7 +631,7 @@ def log(
635631 body = body ,
636632 artifacts = artefacts or None ,
637633 source = src_str ,
638- rel_source = None if full_paths else _rel_to_cwd (src_str ),
634+ rel_source = _rel_to_cwd (src_str ),
639635 lineno = getattr (test , "lineno" , None ) or None ,
640636 elapsed_seconds = _elapsed_seconds (test ),
641637 start_time = _iso (_start_time (test )),
@@ -1008,11 +1004,11 @@ def _eligible(t: Any) -> bool:
10081004 for name , cur in current_tests .items ():
10091005 base = baseline_tests .get (name )
10101006 if base is None :
1011- added .append (_make_diff_change (name , None , cur , message_chars = message_chars , full_paths = full_paths ))
1007+ added .append (_make_diff_change (name , None , cur , message_chars = message_chars ))
10121008 continue
10131009 if base .status == cur .status :
10141010 continue
1015- change = _make_diff_change (name , base , cur , message_chars = message_chars , full_paths = full_paths )
1011+ change = _make_diff_change (name , base , cur , message_chars = message_chars )
10161012 if base .status == "PASS" and cur .status in ("FAIL" , "ERROR" ):
10171013 new_failures .append (change )
10181014 elif base .status in ("FAIL" , "ERROR" , "SKIP" ) and cur .status == "PASS" :
@@ -1022,7 +1018,7 @@ def _eligible(t: Any) -> bool:
10221018
10231019 for name , base in baseline_tests .items ():
10241020 if name not in current_tests :
1025- removed .append (_make_diff_change (name , base , None , message_chars = message_chars , full_paths = full_paths ))
1021+ removed .append (_make_diff_change (name , base , None , message_chars = message_chars ))
10261022
10271023 selected = {c .lower () for c in only_categories } if only_categories else None
10281024
@@ -1072,7 +1068,6 @@ def _make_diff_change(
10721068 current_test : Any ,
10731069 * ,
10741070 message_chars : int ,
1075- full_paths : bool ,
10761071) -> DiffChange :
10771072 """Build a DiffChange capturing baseline/current status, message, and source."""
10781073 src_test = current_test if current_test is not None else baseline_test
@@ -1089,7 +1084,7 @@ def _make_diff_change(
10891084 if current_test is not None
10901085 else None ,
10911086 source = src_str ,
1092- rel_source = None if full_paths else _rel_to_cwd (src_str ),
1087+ rel_source = _rel_to_cwd (src_str ),
10931088 lineno = getattr (src_test , "lineno" , None ) or None ,
10941089 )
10951090
@@ -1471,23 +1466,29 @@ def _sort_items(items: List[TestResultItem], field: Optional[str], reverse: bool
14711466
14721467
14731468def _rel_to_cwd (p : Optional [str ]) -> Optional [str ]:
1469+ """Return the source path as relative-to-cwd if possible, else the
1470+ original path. Mirrors `discover.get_rel_source`: `rel_source` in
1471+ JSON is always non-None when `source` is set, falling back to the
1472+ absolute path when the source isn't anchored under cwd. The schema
1473+ invariant matters for consumers like the VS Code extension which
1474+ rely on `relSource` being present.
1475+ """
14741476 if p is None :
14751477 return None
14761478 try :
14771479 return str (Path (p ).relative_to (Path .cwd ()).as_posix ())
14781480 except ValueError :
1479- return None
1481+ return p
14801482
14811483
14821484def _make_file_info (path : Path ) -> ResultFileInfo :
1483- rel = _rel_to_cwd (str (path ))
14841485 return ResultFileInfo (
14851486 source = str (path ),
1486- rel_source = rel if rel and rel != str (path ) else None ,
1487+ rel_source = _rel_to_cwd ( str (path )) ,
14871488 )
14881489
14891490
1490- def _make_test_item (test : Any , * , message_chars : int , full_paths : bool ) -> TestResultItem :
1491+ def _make_test_item (test : Any , * , message_chars : int ) -> TestResultItem :
14911492 msg = test .message or ""
14921493 first_line = msg .splitlines ()[0 ] if msg else ""
14931494 truncated_msg = first_line
@@ -1513,7 +1514,7 @@ def _make_test_item(test: Any, *, message_chars: int, full_paths: bool) -> TestR
15131514 elapsed_seconds = _elapsed_seconds (test ),
15141515 start_time = _iso (_start_time (test )),
15151516 source = src_str ,
1516- rel_source = None if full_paths else rel_src ,
1517+ rel_source = rel_src ,
15171518 lineno = getattr (test , "lineno" , None ) or None ,
15181519 )
15191520
@@ -1522,7 +1523,6 @@ def _collect_failures(
15221523 suite : Any ,
15231524 status_filters : Tuple [str , ...],
15241525 * ,
1525- full_paths : bool = False ,
15261526 match : Optional ["SearchMatcher" ] = None ,
15271527) -> List [TestResultItem ]:
15281528 """Return all failed tests (post-tree-filter, after status filter) with msgs."""
@@ -1535,7 +1535,7 @@ def _collect_failures(
15351535 continue
15361536 if match is not None and not _raw_test_search_matches (t , match ):
15371537 continue
1538- out .append (_make_test_item (t , message_chars = 0 , full_paths = full_paths ))
1538+ out .append (_make_test_item (t , message_chars = 0 ))
15391539 return out
15401540
15411541
0 commit comments