aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xEasyInstall.txt10
-rw-r--r--setuptools/command/test.py44
-rw-r--r--setuptools/tests/__init__.py10
3 files changed, 35 insertions, 29 deletions
diff --git a/EasyInstall.txt b/EasyInstall.txt
index 8227b530..d9b7b26f 100755
--- a/EasyInstall.txt
+++ b/EasyInstall.txt
@@ -484,8 +484,14 @@ Known Issues
0.5a5
* Added ``egg_info`` command to ``setuptools``-based packages. This command
just creates or updates the "projectname.egg-info" directory, without
- building an egg. It's used by the ``bdist_egg`` command now, and will be
- used by the ``test`` and ``develop`` commands later on.
+ building an egg. It's used by the ``bdist_egg`` and ``test`` commands now,
+ and will be used by the ``develop`` command later on.
+
+ * Enhanced the ``test`` command so that it doesn't install the package, but
+ instead builds any C extensions in-place, updates the ``.egg-info``
+ metadata, adds the source directory to ``sys.path``, and runs the tests
+ directly on the source. This avoids an "unmanaged" installation of the
+ package to ``site-packages`` or elsewhere.
0.5a4
* Added ``--always-copy/-a`` option to always copy needed packages to the
diff --git a/setuptools/command/test.py b/setuptools/command/test.py
index 6b37a9fd..37aeac68 100644
--- a/setuptools/command/test.py
+++ b/setuptools/command/test.py
@@ -1,4 +1,4 @@
-from distutils.cmd import Command
+from setuptools import Command
from distutils.errors import DistutilsOptionError
import sys
@@ -40,35 +40,35 @@ class test(Command):
def run(self):
+ # Ensure metadata is up-to-date
+ self.run_command('egg_info')
- # Install before testing
- self.run_command('install')
+ # Build extensions in-place
+ self.reinitialize_command('build_ext', inplace=1)
+ self.run_command('build_ext')
if self.test_suite:
cmd = ' '.join(self.test_args)
-
if self.dry_run:
self.announce('skipping "unittest %s" (dry run)' % cmd)
else:
self.announce('running "unittest %s"' % cmd)
- import unittest
- unittest.main(None, None, [unittest.__file__]+self.test_args)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ self.run_tests()
+
+ def run_tests(self):
+ import unittest, pkg_resources
+ old_path = sys.path[:]
+ ei_cmd = self.get_finalized_command("egg_info")
+ try:
+ # put the egg on sys.path, and require() it
+ sys.path.insert(0, ei_cmd.egg_base)
+ pkg_resources.require(
+ "%s==%s" % (ei_cmd.egg_name, ei_cmd.egg_version)
+ )
+ unittest.main(None, None, [unittest.__file__]+self.test_args)
+ finally:
+ sys.path[:] = old_path
+ # XXX later this might need to save/restore the WorkingSet
diff --git a/setuptools/tests/__init__.py b/setuptools/tests/__init__.py
index 7db37888..06ca095d 100644
--- a/setuptools/tests/__init__.py
+++ b/setuptools/tests/__init__.py
@@ -122,19 +122,19 @@ class DependsTests(TestCase):
def testDependsCmd(self):
- path1 = convert_path('foo/bar/baz')
- path2 = convert_path('foo/bar/baz/spam')
+ path = convert_path('foo/bar/baz')
dist = makeSetup(
- extra_path='spam',
- script_args=['install','--install-lib',path1]
+ script_args=['install','--install-lib',path]
)
cmd = dist.get_command_obj('depends')
cmd.ensure_finalized()
self.assertEqual(cmd.temp, dist.get_command_obj('build').build_temp)
- self.assertEqual(cmd.search_path, [path2,path1]+sys.path)
+ self.assertEqual(cmd.search_path, [path+os.path.sep,path]+sys.path)
+
+