diff options
author | Pauli Virtanen <pav@iki.fi> | 2009-08-29 18:37:35 +0000 |
---|---|---|
committer | Pauli Virtanen <pav@iki.fi> | 2009-08-29 18:37:35 +0000 |
commit | 1df22350f35b957cff5d29ea1ae5299946a5295b (patch) | |
tree | 7ecc1c17ffcf5c16a93e95b52c2af7d2bb1c10d3 /numpy/testing/nosetester.py | |
parent | 3253b06df613ffd152e655ec6c3477b724640dd7 (diff) | |
download | numpy-1df22350f35b957cff5d29ea1ae5299946a5295b.tar.gz |
Fix #1168: fix functionality broken in r7132, and make get_package_path more robust
Diffstat (limited to 'numpy/testing/nosetester.py')
-rw-r--r-- | numpy/testing/nosetester.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/numpy/testing/nosetester.py b/numpy/testing/nosetester.py index a818e5e62..c4b8063de 100644 --- a/numpy/testing/nosetester.py +++ b/numpy/testing/nosetester.py @@ -7,12 +7,13 @@ import os import sys def get_package_name(filepath): - # find the package name given a path name that's part of the package + """Given a path where a package is installed, determine its name""" + fullpath = filepath[:] pkg_name = [] - while 'site-packages' in filepath: + while 'site-packages' in filepath or 'dist-packages' in filepath: filepath, p2 = os.path.split(filepath) - if p2 == 'site-packages': + if p2 in ('site-packages', 'dist-packages'): break pkg_name.append(p2) @@ -25,6 +26,11 @@ def get_package_name(filepath): # otherwise, reverse to get correct order and return pkg_name.reverse() + + # don't include the outer egg directory + if pkg_name[0].endswith('.egg'): + pkg_name.pop(0) + return '.'.join(pkg_name) def import_nose(): @@ -125,6 +131,9 @@ class NoseTester(object): elif isinstance(package, type(os)): package_path = os.path.dirname(package.__file__) package_name = getattr(package, '__name__', None) + else: + package_path = str(package) + self.package_path = package_path # find the package name under test; this name is used to limit coverage |