From 8b74269476d72e2e05a6f7ff35d693b816e9457c Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 6 Apr 2014 18:33:37 -0400 Subject: Wrap unittest.main in a compatibility wrapper for Python 3.1 compatibility. Fixes #183 --- setuptools/py31compat.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'setuptools/py31compat.py') 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) -- cgit v1.2.3