diff --git a/coverage/files.py b/coverage/files.py index ec1aaf56f..5cad254ee 100644 --- a/coverage/files.py +++ b/coverage/files.py @@ -406,7 +406,7 @@ def find_python_files(dirname, include_namespace_packages): """ for i, (dirpath, dirnames, filenames) in enumerate(os.walk(dirname)): - if (i > 0 and '__init__.py' not in filenames + if (i > 0 and '__init__.py' not in filenames and not include_namespace_packages): # If a directory doesn't have __init__.py, then it isn't # importable and neither are its files diff --git a/coverage/inorout.py b/coverage/inorout.py index ad7722578..780935282 100644 --- a/coverage/inorout.py +++ b/coverage/inorout.py @@ -567,7 +567,7 @@ def _find_executable_files(self, src_dir): """ py_files = ( - (py_file, None) for py_file in + (py_file, None) for py_file in find_python_files(src_dir, self.include_namespace_packages) ) plugin_files = self._find_plugin_files(src_dir) diff --git a/tests/test_cmdline.py b/tests/test_cmdline.py index e52fec7ff..624ae972f 100644 --- a/tests/test_cmdline.py +++ b/tests/test_cmdline.py @@ -61,8 +61,8 @@ class BaseCmdLineTest(CoverageTest): _defaults.Coverage( data_file=DEFAULT_DATAFILE, cover_pylib=None, data_suffix=None, timid=None, branch=None, - config_file=True, source=None, include=None, include_namespace_packages=False, - omit=None, debug=None, concurrency=None, check_preimported=True, context=None, + config_file=True, source=None, include=None, include_namespace_packages=False, + omit=None, debug=None, concurrency=None, check_preimported=True, context=None, messages=True, ) diff --git a/tests/test_files.py b/tests/test_files.py index b217389de..8ea6daf02 100644 --- a/tests/test_files.py +++ b/tests/test_files.py @@ -427,7 +427,7 @@ def test_find_python_files_include_namespace_packages(self): self.make_file("sub/ssub/__init__.py") self.make_file("sub/ssub/s.py") self.make_file("sub/ssub/~s.py") # nope: editor effluvia - self.make_file("sub/lab/exp.py") + self.make_file("sub/lab/exp.py") self.make_file("sub/windows.pyw") py_files = set(find_python_files("sub", True)) self.assert_same_files(py_files, [