[Python-checkins] python/nondist/sandbox/setuptools/setuptools/command test.py, 1.3, 1.4

pje@users.sourceforge.net pje at users.sourceforge.net
Thu Jul 21 02:51:09 CEST 2005


Update of /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/command
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31008/setuptools/command

Modified Files:
	test.py 
Log Message:
Make 'test' command work correctly with the 0.6 WorkingSet class.


Index: test.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/command/test.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- test.py	6 Jul 2005 03:46:16 -0000	1.3
+++ test.py	21 Jul 2005 00:51:07 -0000	1.4
@@ -1,6 +1,7 @@
 from setuptools import Command
 from distutils.errors import DistutilsOptionError
 import sys
+from pkg_resources import *
 
 class test(Command):
 
@@ -38,7 +39,6 @@
         if self.verbose:
             self.test_args.insert(0,'--verbose')
 
-
     def run(self):
         # Ensure metadata is up-to-date
         self.run_command('egg_info')
@@ -56,19 +56,19 @@
                 self.run_tests()
 
     def run_tests(self):
-        import unittest, pkg_resources
+        import unittest
         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
+        path_item = normalize_path(ei_cmd.egg_base)
+        metadata = PathMetadata(
+            path_item, normalize_path(ei_cmd.egg_info)
+        )
+        dist = Distribution(path_item, metadata, project_name=ei_cmd.egg_name)
+        working_set.add(dist)
+        require(str(dist.as_requirement()))
+        unittest.main(None, None, [unittest.__file__]+self.test_args)
+
+
 
 
 



More information about the Python-checkins mailing list