summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/_pytest/main.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/_pytest/main.py b/src/_pytest/main.py
index 93073226c..41a33d449 100644
--- a/src/_pytest/main.py
+++ b/src/_pytest/main.py
@@ -775,12 +775,14 @@ class Session(nodes.FSCollector):
self._notfound.append((report_arg, col))
continue
- # If __init__.py was the only file requested, then the matched node will be
- # the corresponding Package, and the first yielded item will be the __init__
- # Module itself, so just use that. If this special case isn't taken, then all
- # the files in the package will be yielded.
- if argpath.basename == "__init__.py":
- assert isinstance(matching[0], nodes.Collector)
+ # If __init__.py was the only file requested, then the matched
+ # node will be the corresponding Package (by default), and the
+ # first yielded item will be the __init__ Module itself, so
+ # just use that. If this special case isn't taken, then all the
+ # files in the package will be yielded.
+ if argpath.basename == "__init__.py" and isinstance(
+ matching[0], Package
+ ):
try:
yield next(iter(matching[0].collect()))
except StopIteration: