Skip to content

Commit 649477c

Browse files
committed
Add test_name_formatter
1 parent 363c1f6 commit 649477c

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/pytest_mypy/__init__.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ def serialized(self) -> str:
5757
terminal_summary_title = "mypy"
5858

5959

60+
def default_test_name_formatter(*, item: MypyFileItem) -> str:
61+
path = item.path.relative_to(item.config.invocation_params.dir)
62+
return f"[{terminal_summary_title}] {path}"
63+
64+
65+
test_name_formatter = default_test_name_formatter
66+
67+
6068
def default_file_error_formatter(
6169
item: MypyItem,
6270
results: MypyResults,
@@ -268,13 +276,9 @@ def runtest(self) -> None:
268276
)
269277
)
270278

271-
def reportinfo(self) -> Tuple[str, None, str]:
279+
def reportinfo(self) -> Tuple[Path, None, str]:
272280
"""Produce a heading for the test report."""
273-
return (
274-
str(self.path),
275-
None,
276-
str(self.path.relative_to(self.config.invocation_params.dir)),
277-
)
281+
return (self.path, None, test_name_formatter(item=self))
278282

279283

280284
class MypyStatusItem(MypyItem):

0 commit comments

Comments
 (0)