Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 320e41b commit 5ac4effCopy full SHA for 5ac4eff
src/_pytest/main.py
@@ -542,7 +542,15 @@ def _collect(self, arg):
542
col = root._collectfile(argpath)
543
if col:
544
self._node_cache[argpath] = col
545
- for y in self.matchnodes(col, names):
+ m = self.matchnodes(col, names)
546
+ # If __init__.py was the only file requested, then the matched node will be
547
+ # the corresponding Package, and the first yielded item will be the __init__
548
+ # Module itself, so just use that. If this special case isn't taken, then all
549
+ # the files in the package will be yielded.
550
+ if argpath.basename == "__init__.py":
551
+ yield next(m[0].collect())
552
+ return
553
+ for y in m:
554
yield y
555
556
def _collectfile(self, path):
0 commit comments