summaryrefslogtreecommitdiff
path: root/selftest.py
diff options
context:
space:
mode:
authorAlex Stewart <alex@foogod.com>2010-08-27 17:47:00 -0700
committerAlex Stewart <alex@foogod.com>2010-08-27 17:47:00 -0700
commitbbe7ec73479aeac7e69623d7e4fa3d6fc92a8988 (patch)
tree2858e9773b4ce0f790b925d8a800cbf903002a06 /selftest.py
parent25aee297bbc98fa69076913938fc7bc9435775dc (diff)
downloadnose-bbe7ec73479aeac7e69623d7e4fa3d6fc92a8988.tar.gz
More 3.x fixes: Created 'build_tests' command for setup.py and modified selftest.py to run tests from the build dir if it's present.
Diffstat (limited to 'selftest.py')
-rw-r--r--[-rwxr-xr-x]selftest.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/selftest.py b/selftest.py
index f09e0c9..5102182 100755..100644
--- a/selftest.py
+++ b/selftest.py
@@ -29,15 +29,25 @@ import sys
if __name__ == "__main__":
this_dir = os.path.normpath(os.path.abspath(os.path.dirname(__file__)))
+ lib_dir = this_dir
+ if os.path.isdir(os.path.join(this_dir, 'build', 'lib', 'nose')):
+ # In some cases (for example, Python 3.x), we may have to build an
+ # alternate version of the source (under build/lib) which we want to be
+ # using instead of the source dir. If there's a build/lib/nose
+ # directory, use that.
+ this_dir = os.path.join(this_dir, 'build')
+ lib_dir = os.path.join(this_dir, 'lib')
try:
import pkg_resources
- except ImportError:
- sys.path.insert(0, this_dir)
- else:
- env = pkg_resources.Environment(search_path=[this_dir])
+ env = pkg_resources.Environment(search_path=[lib_dir])
distributions = env["nose"]
assert len(distributions) == 1
dist = distributions[0]
dist.activate()
+ except ImportError:
+ pass
+ # Always make sure our chosen version is first on the path
+ sys.path.insert(0, lib_dir)
+ os.chdir(this_dir)
import nose
nose.run_exit()