[Jython-checkins] jython: More precisely specify versions of Java in test_codecencodings_tw.
jeff.allen
jython-checkins at python.org
Sun Mar 19 20:10:33 EDT 2017
https://hg.python.org/jython/rev/cc731a59c5eb
changeset: 8069:cc731a59c5eb
user: Jeff Allen <ja.py at farowl.co.uk>
date: Mon Mar 20 00:09:00 2017 +0000
summary:
More precisely specify versions of Java in test_codecencodings_tw.
Second attempt at fixing #2571. The change in coded behaviour seems to
occur within Java 7, after 1.7.0_60, not between that and Java 8. We
make test_support.get_java_version return the precise version in support
of this test.
files:
Lib/test/test_codecencodings_tw.py | 14 +++++++++-----
Lib/test/test_support.py | 16 +++++++++++++---
2 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/Lib/test/test_codecencodings_tw.py b/Lib/test/test_codecencodings_tw.py
--- a/Lib/test/test_codecencodings_tw.py
+++ b/Lib/test/test_codecencodings_tw.py
@@ -9,11 +9,15 @@
import unittest
import sys
-# Codecs re-synchronise sooner after illegal byte in Java 8+ than in Java 7
-# (and in CPython 3.3+ than in CPython 2.7-3.2). Either is correct, but we
-# need to know which one to expect.
-RESYNC_FASTER = sys.platform.startswith('java') and \
- sys.platform[4:7] > "1.7"
+# Codecs re-synchronise faster after illegal byte in Java 8+ than in Java 7 to
+# update 60 (and in CPython 3.3+ faster than in CPython 2.7-3.2). Either is
+# correct, but we need to know which one to expect.
+RESYNC_FASTER = False # True for CPython 3.3 and later
+
+if sys.platform.startswith('java'):
+ if test_support.get_java_version() > (1, 7, 0, 60):
+ RESYNC_FASTER = True
+
class Test_Big5(test_multibytecodec_support.TestBase, unittest.TestCase):
encoding = 'big5'
diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py
--- a/Lib/test/test_support.py
+++ b/Lib/test/test_support.py
@@ -55,9 +55,19 @@
is_jython_posix = is_jython and (os._name == 'posix')
if is_jython:
- def get_java_version():
- # returns (1, 9) for Java 9, etc
- return tuple((int(x) for x in platform.java_ver()[0].split('.')[0:2]))
+ def get_java_version(version=None):
+ # returns (1, 8, 0, 121) for version = "1.8.0_121", meaning
+ # Java 8 update 121, etc.. Conforms to:
+ # http://www.oracle.com/technetwork/java/javase/versioning-naming-139433.html
+ # and not yet http://openjdk.java.net/jeps/223 .
+ if version is None:
+ version = platform.java_ver()[0]
+ parse = re.match("(\d+)\.(\d+)\.(\d+)_(\d+)", version)
+ if parse:
+ return tuple((int(x) for x in parse.groups()))
+ else:
+ return ()
+
class Error(Exception):
"""Base class for regression test exceptions."""
--
Repository URL: https://hg.python.org/jython
More information about the Jython-checkins
mailing list