summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRan Benita <ran@unusedvar.com>2020-11-13 10:46:46 +0200
committerGitHub <noreply@github.com>2020-11-13 10:46:46 +0200
commit66311ff702d98450f29a448a47c0cd5fd0c51081 (patch)
tree9e7f9c4d03b99153334d8d7f87a9c9b8ab245ad5 /src
parentea3c0aa245b927d7937f86041c1991ab534d07e5 (diff)
parent265cc2cfece4ee5a2094b7c02dd80cd6099af60f (diff)
downloadpytest-66311ff702d98450f29a448a47c0cd5fd0c51081.tar.gz
Merge pull request #8022 from bluetech/doctest-init
main: fix only one doctest collected on pytest --doctest-modules __init__.py
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: