Fixed SyntaxError when installing via Python 3
This commit is contained in:
3
NEWS
3
NEWS
@@ -21,6 +21,9 @@ Improvements
|
||||
create a synthetic test recording any such exception.
|
||||
(Robert Collins, #1130429)
|
||||
|
||||
* Fixed SyntaxError raised in ``_compat2x.py`` when installing via Python 3.
|
||||
(Will Bond, #941958)
|
||||
|
||||
* New class ``StreamResult`` which defines the API for the new result type.
|
||||
(Robert Collins)
|
||||
|
||||
|
||||
10
setup.py
10
setup.py
@@ -2,8 +2,10 @@
|
||||
"""Distutils installer for testtools."""
|
||||
|
||||
from setuptools import setup
|
||||
from distutils.command.build_py import build_py
|
||||
import email
|
||||
import os
|
||||
import sys
|
||||
|
||||
import testtools
|
||||
cmd_class = {}
|
||||
@@ -11,6 +13,14 @@ if getattr(testtools, 'TestCommand', None) is not None:
|
||||
cmd_class['test'] = testtools.TestCommand
|
||||
|
||||
|
||||
class testtools_build_py(build_py):
|
||||
def build_module(self, module, module_file, package):
|
||||
if sys.version_info >= (3,) and module == '_compat2x':
|
||||
return
|
||||
return build_py.build_module(self, module, module_file, package)
|
||||
cmd_class['build_py'] = testtools_build_py
|
||||
|
||||
|
||||
def get_version_from_pkg_info():
|
||||
"""Get the version from PKG-INFO file if we can."""
|
||||
pkg_info_path = os.path.join(os.path.dirname(__file__), 'PKG-INFO')
|
||||
|
||||
@@ -35,7 +35,7 @@ StringIO = try_imports(['StringIO.StringIO', 'io.StringIO'])
|
||||
|
||||
try:
|
||||
from testtools import _compat2x as _compat
|
||||
except SyntaxError:
|
||||
except (SyntaxError, ImportError):
|
||||
from testtools import _compat3x as _compat
|
||||
|
||||
reraise = _compat.reraise
|
||||
|
||||
Reference in New Issue
Block a user