Hi all,

for our nightly build system I needed the capability to use a different
test runner, namely one that outputs junit compatible xml files.
In order to support that through the setup.py test command I hacked on
setuptools.

Is there a simpler way to do this?
If not you might want to consider attached patch for addition
(Should be against latest svn.)

Cheers,
Klaus
diff --git a/setup.py b/setup.py
index 4a73beb..813b037 100755
--- a/setup.py
+++ b/setup.py
@@ -53,6 +53,7 @@ setup(
             "include_package_data = setuptools.dist:assert_bool",
             "dependency_links     = setuptools.dist:assert_string_list",
             "test_loader          = setuptools.dist:check_importable",
+            "test_runner          = setuptools.dist:check_importable",
         ],
         "egg_info.writers": [
             "PKG-INFO = setuptools.command.egg_info:write_pkg_info",
diff --git a/setuptools.egg-info/entry_points.txt b/setuptools.egg-info/entry_points.txt
index f7367e0..84f8f83 100755
--- a/setuptools.egg-info/entry_points.txt
+++ b/setuptools.egg-info/entry_points.txt
@@ -40,6 +40,7 @@ svn_cvs = setuptools.command.sdist:_default_revctrl
 dependency_links = setuptools.dist:assert_string_list
 entry_points = setuptools.dist:check_entry_points
 extras_require = setuptools.dist:check_extras
+test_runner = setuptools.dist:check_importable
 package_data = setuptools.dist:check_package_data
 install_requires = setuptools.dist:check_requirements
 include_package_data = setuptools.dist:assert_bool
diff --git a/setuptools/command/test.py b/setuptools/command/test.py
index db918da..6fcf1df 100644
--- a/setuptools/command/test.py
+++ b/setuptools/command/test.py
@@ -49,9 +49,11 @@ class test(Command):
         ('test-module=','m', "Run 'test_suite' in specified module"),
         ('test-suite=','s',
             "Test suite to run (e.g. 'some_module.test_suite')"),
+        ('test-runner=','r', "Test runner to use"),
     ]
 
     def initialize_options(self):
+        self.test_runner = None
         self.test_suite = None
         self.test_module = None
         self.test_loader = None
@@ -77,7 +79,8 @@ class test(Command):
             self.test_loader = getattr(self.distribution,'test_loader',None)
         if self.test_loader is None:
             self.test_loader = "setuptools.command.test:ScanningLoader"
-
+        if self.test_runner is None:
+            self.test_runner = getattr(self.distribution,'test_runner',None)
 
 
     def with_project_on_sys_path(self, func):
@@ -125,40 +128,16 @@ class test(Command):
         import unittest
         loader_ep = EntryPoint.parse("x="+self.test_loader)
         loader_class = loader_ep.load(require=False)
-        unittest.main(
-            None, None, [unittest.__file__]+self.test_args,
-            testLoader = loader_class()
-        )
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+        if self.test_runner == None:
+            unittest.main(
+                None, None, [unittest.__file__]+self.test_args,
+                testLoader = loader_class()
+            )
+        else:
+            runner_ep = EntryPoint.parse("x="+self.test_runner)
+            runner_class = runner_ep.load(require=False)
+            unittest.main(
+                None, None, [unittest.__file__]+self.test_args,
+                testRunner = runner_class(),
+                testLoader = loader_class()
+            )
_______________________________________________
Distutils-SIG maillist  -  Distutils-SIG@python.org
http://mail.python.org/mailman/listinfo/distutils-sig

Reply via email to