Commit a462bb3f authored by PJ Eby's avatar PJ Eby

Make 'test' command work correctly with the 0.6 WorkingSet class.

--HG--
branch : setuptools
extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041140
parent 2a8ed3cc
from setuptools import Command from setuptools import Command
from distutils.errors import DistutilsOptionError from distutils.errors import DistutilsOptionError
import sys import sys
from pkg_resources import *
class test(Command): class test(Command):
...@@ -38,7 +39,6 @@ class test(Command): ...@@ -38,7 +39,6 @@ class test(Command):
if self.verbose: if self.verbose:
self.test_args.insert(0,'--verbose') self.test_args.insert(0,'--verbose')
def run(self): def run(self):
# Ensure metadata is up-to-date # Ensure metadata is up-to-date
self.run_command('egg_info') self.run_command('egg_info')
...@@ -56,19 +56,19 @@ class test(Command): ...@@ -56,19 +56,19 @@ class test(Command):
self.run_tests() self.run_tests()
def run_tests(self): def run_tests(self):
import unittest, pkg_resources import unittest
old_path = sys.path[:] old_path = sys.path[:]
ei_cmd = self.get_finalized_command("egg_info") ei_cmd = self.get_finalized_command("egg_info")
try: path_item = normalize_path(ei_cmd.egg_base)
# put the egg on sys.path, and require() it metadata = PathMetadata(
sys.path.insert(0, ei_cmd.egg_base) path_item, normalize_path(ei_cmd.egg_info)
pkg_resources.require( )
"%s==%s" % (ei_cmd.egg_name, ei_cmd.egg_version) dist = Distribution(path_item, metadata, project_name=ei_cmd.egg_name)
) working_set.add(dist)
unittest.main(None, None, [unittest.__file__]+self.test_args) require(str(dist.as_requirement()))
finally: unittest.main(None, None, [unittest.__file__]+self.test_args)
sys.path[:] = old_path
# XXX later this might need to save/restore the WorkingSet
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment