From dcdf86ef5bdfffddbed6e5748ea83553a5294370 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Fri, 26 Oct 2018 16:06:16 +0200 Subject: [PATCH] python: collect: revisit --- src/_pytest/python.py | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/_pytest/python.py b/src/_pytest/python.py index 6b17b36ff..c280fc0a1 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -560,19 +560,16 @@ class Package(Module): yield Module(init_module, self) pkg_prefixes = set() for path in this_path.visit(rec=self._recurse, bf=True, sort=True): - # we will visit our own __init__.py file, in which case we skip it - skip = False - if path.basename == "__init__.py" and path.dirpath() == this_path: - continue + # We will visit our own __init__.py file, in which case we skip it. + if path.isfile(): + if path.basename == "__init__.py" and path.dirpath() == this_path: + continue - for pkg_prefix in pkg_prefixes: - if ( - pkg_prefix in path.parts() - and pkg_prefix.join("__init__.py") != path - ): - skip = True - - if skip: + parts = path.parts() + if any( + pkg_prefix in parts and pkg_prefix.join("__init__.py") != path + for pkg_prefix in pkg_prefixes + ): continue if path.isdir() and path.join("__init__.py").check(file=1):