diff options
author | Jason Pellerin <jpellerin@gmail.com> | 2008-03-25 02:11:51 +0000 |
---|---|---|
committer | Jason Pellerin <jpellerin@gmail.com> | 2008-03-25 02:11:51 +0000 |
commit | d684f2f19a37d7b8314b3d1d3fc2b8fe813b1b9a (patch) | |
tree | de8f6e6aab672b4f2e70209283dac911c6900694 | |
parent | abf2eb507de6d885f9c211aeebb0a8864958ae28 (diff) | |
download | nose-d684f2f19a37d7b8314b3d1d3fc2b8fe813b1b9a.tar.gz |
Fixed issue 49
-rwxr-xr-x | selftest.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/selftest.py b/selftest.py new file mode 100755 index 0000000..f09e0c9 --- /dev/null +++ b/selftest.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python + +"""Test the copy of nose in this directory, by running that nose against itself. + +You can test nose using nose in other ways, but if you don't use this script, +you might have one installation of nose testing another installation, which is +not supported. +""" + +# More detail: + +# In the absence of some sort of deep renaming magic, nose can't reasonably +# test a different installation of itself, given the existence of the global +# module registry sys.modules . + +# If installed system-wide with setuptools, setuptools (via the site-packages +# easy-install.pth) takes you at your word and ensures that the installed nose +# comes first on sys.path . So the only way to test a copy of nose other than +# the installed one is to install that version (e.g. by running python setup.py +# develop). + +# This script provides a way of running nose on nose's own tests without +# installing the version to be tested, nor uninstalling the currently-installed +# version. + +import os +import sys + + +if __name__ == "__main__": + this_dir = os.path.normpath(os.path.abspath(os.path.dirname(__file__))) + try: + import pkg_resources + except ImportError: + sys.path.insert(0, this_dir) + else: + env = pkg_resources.Environment(search_path=[this_dir]) + distributions = env["nose"] + assert len(distributions) == 1 + dist = distributions[0] + dist.activate() + import nose + nose.run_exit() |