Skip to content

Commit 1f10c59

Browse files
authored
Clarify error message in case no collectors are found for a file
1 parent 00ad12b commit 1f10c59

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/_pytest/main.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -645,9 +645,12 @@ def perform_collect(
645645
self.trace.root.indent -= 1
646646
if self._notfound:
647647
errors = []
648-
for arg, cols in self._notfound:
649-
line = f"(no name {arg!r} in any of {cols!r})"
650-
errors.append(f"not found: {arg}\n{line}")
648+
for arg, collectors in self._notfound:
649+
if cols:
650+
errors.append(f"not found: {arg}\n(no name {arg!r} in any of {collectors!r})")
651+
else:
652+
errors.append(f"found no collectors for {arg}")
653+
651654
raise UsageError(*errors)
652655
if not genitems:
653656
items = rep.result

0 commit comments

Comments
 (0)