Merge branch 'fix-py27-tests'
commit
22a1d3f1fa
|
|
@ -2,6 +2,7 @@
|
||||||
"""Run doctests."""
|
"""Run doctests."""
|
||||||
|
|
||||||
import doctest
|
import doctest
|
||||||
|
import platform
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
@ -10,11 +11,26 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
def _is_new_jpype():
|
||||||
|
if platform.python_implementation() != 'Jython':
|
||||||
|
import jpype
|
||||||
|
try:
|
||||||
|
ver_match = re.match('\d+\.\d+', jpype.__version__)
|
||||||
|
if ver_match:
|
||||||
|
jpype_ver = float(ver_match.group(0))
|
||||||
|
if jpype_ver >= 0.7:
|
||||||
|
return True
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
return False
|
||||||
|
|
||||||
class Py23DocChecker(doctest.OutputChecker):
|
class Py23DocChecker(doctest.OutputChecker):
|
||||||
"""Doctest checker to avoid Python 2/3 unicode comparison
|
"""Doctest checker to avoid Python 2/3 unicode comparison
|
||||||
issues. Code taken from Dirkjan Ochtman"""
|
issues. Code mostly taken from Dirkjan Ochtman"""
|
||||||
def check_output(self, want, got, optionflags):
|
def check_output(self, want, got, optionflags):
|
||||||
if sys.version_info[0] > 2:
|
if sys.version_info[0] > 2 or _is_new_jpype():
|
||||||
|
# new python has unicode as default
|
||||||
|
# new JPype does not automatically convert to unicode on Python 2
|
||||||
want = re.sub("u'(.*?)'", "'\\1'", want)
|
want = re.sub("u'(.*?)'", "'\\1'", want)
|
||||||
want = re.sub('u"(.*?)"', '"\\1"', want)
|
want = re.sub('u"(.*?)"', '"\\1"', want)
|
||||||
return doctest.OutputChecker.check_output(self, want, got, optionflags)
|
return doctest.OutputChecker.check_output(self, want, got, optionflags)
|
||||||
|
|
|
||||||
2
tox.ini
2
tox.ini
|
|
@ -21,7 +21,7 @@ deps =
|
||||||
oldjpype: JPype1==0.6.3
|
oldjpype: JPype1==0.6.3
|
||||||
py35-newjpype: JPype1==0.7.5
|
py35-newjpype: JPype1==0.7.5
|
||||||
py36-newjpype: JPype1==0.7.5
|
py36-newjpype: JPype1==0.7.5
|
||||||
py27-newjpype: JPype1==0.7.0
|
py27-newjpype: JPype1==0.7.1
|
||||||
jip==0.9.15
|
jip==0.9.15
|
||||||
coverage==4.5.4
|
coverage==4.5.4
|
||||||
commands =
|
commands =
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue