aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2014-04-06 18:33:37 -0400
committerJason R. Coombs <jaraco@jaraco.com>2014-04-06 18:33:37 -0400
commit8b74269476d72e2e05a6f7ff35d693b816e9457c (patch)
tree6be6fffca0cf77839b60ef9585b0eaa925874669
parentd5f19d2efb05693cf0934e8fc32f6c2b71ee6e38 (diff)
downloadexternal_python_setuptools-8b74269476d72e2e05a6f7ff35d693b816e9457c.tar.gz
external_python_setuptools-8b74269476d72e2e05a6f7ff35d693b816e9457c.tar.bz2
external_python_setuptools-8b74269476d72e2e05a6f7ff35d693b816e9457c.zip
Wrap unittest.main in a compatibility wrapper for Python 3.1 compatibility. Fixes #1833.4.2
-rw-r--r--CHANGES.txt6
-rw-r--r--setuptools/command/test.py11
-rw-r--r--setuptools/py31compat.py15
3 files changed, 28 insertions, 4 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index fbfb4885..5980f7af 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -3,6 +3,12 @@ CHANGES
=======
-----
+3.4.2
+-----
+
+* Issue #183: Fix additional regression in test command on Python 3.1.
+
+-----
3.4.1
-----
diff --git a/setuptools/command/test.py b/setuptools/command/test.py
index e377a781..7422b719 100644
--- a/setuptools/command/test.py
+++ b/setuptools/command/test.py
@@ -1,10 +1,15 @@
+import unittest
+from unittest import TestLoader
+
from setuptools import Command
from distutils.errors import DistutilsOptionError
import sys
from pkg_resources import (resource_listdir, resource_exists,
normalize_path, working_set, _namespace_packages, add_activation_listener,
require, EntryPoint)
-from unittest import TestLoader
+
+from setuptools.py31compat import unittest_main
+
class ScanningLoader(TestLoader):
@@ -141,8 +146,6 @@ class test(Command):
self.with_project_on_sys_path(self.run_tests)
def run_tests(self):
- import unittest
-
# Purge modules under test from sys.modules. The test loader will
# re-import them from the build location. Required when 2to3 is used
# with namespace packages.
@@ -158,7 +161,7 @@ class test(Command):
del_modules.append(name)
list(map(sys.modules.__delitem__, del_modules))
- unittest.main(
+ unittest_main(
None, None, [unittest.__file__]+self.test_args,
testLoader=self._resolve_as_ep(self.test_loader),
testRunner=self._resolve_as_ep(self.test_runner),
diff --git a/setuptools/py31compat.py b/setuptools/py31compat.py
index e6b2910a..6e765582 100644
--- a/setuptools/py31compat.py
+++ b/setuptools/py31compat.py
@@ -1,3 +1,6 @@
+import sys
+import unittest
+
__all__ = ['get_config_vars', 'get_path']
try:
@@ -35,3 +38,15 @@ except ImportError:
except OSError: #removal errors are not the only possible
pass
self.name = None
+
+
+unittest_main = unittest.main
+
+_PY31 = (3, 1) <= sys.version_info[:2] < (3, 2)
+if _PY31:
+ # on Python 3.1, translate testRunner==None to defaultTestLoader
+ # for compatibility with Python 2.6, 2.7, and 3.2+
+ def unittest_main(*args, **kwargs):
+ if 'testRunner' in kwargs and kwargs['testRunner'] is None:
+ kwargs['testRunner'] = unittest.defaultTestLoader
+ return unittest.main(*args, **kwargs)