diff options
author | John Szakmeister <john@szakmeister.net> | 2015-01-25 06:21:43 -0500 |
---|---|---|
committer | John Szakmeister <john@szakmeister.net> | 2015-01-25 09:12:39 -0500 |
commit | d9b92adc1e5a40b10bda5bc3e86abc5bebde2bcf (patch) | |
tree | e24ef2d6f9635b6f95f07741c2434f56f5ac3927 /nose | |
parent | 3510bda1e6fd7cb66fd6bb82f6c560991503fdee (diff) | |
download | nose-d9b92adc1e5a40b10bda5bc3e86abc5bebde2bcf.tar.gz |
Fix #875: nose doesn't collect tests when subpackage is given as arg
When a subpackage is specified on the command line (e.g., `nosetests
foo.bar`), it should pick up all the tests below the subpackage.
The root of the problem came from how we resolved a filename for a
package. We should really point to the package directory, instead of
providing the path to the `__init__.py` file. Otherwise, we only end up
attempting to select modules from the `__init__.py` instead of the whole
tree underneath. We don't want to check for a path ending in
`__init__.py` in `loadTestsFromModule()` because then we select the
whole subtree of tests when `foo/bar/__init__.py` is specified when only
tests in the __init__.py should be selected.
Diffstat (limited to 'nose')
-rw-r--r-- | nose/util.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/nose/util.py b/nose/util.py index e6f735e..efab8fe 100644 --- a/nose/util.py +++ b/nose/util.py @@ -221,11 +221,11 @@ def getfilename(package, relativeTo=None): if relativeTo is None: relativeTo = os.getcwd() path = os.path.join(relativeTo, os.sep.join(package.split('.'))) - suffixes = ('/__init__.py', '.py') - for suffix in suffixes: - filename = path + suffix - if os.path.exists(filename): - return filename + if os.path.exists(path + '/__init__.py'): + return path + filename = path + '.py' + if os.path.exists(filename): + return filename return None |