This repository has been archived by the owner on Apr 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 50
Tests are not compatible with Python 3 #48
Comments
On Wed, 15 Mar 2017, Rémi Verschelde wrote:
I had to disable the tests on the python 3 build of pyicu on Mageia as
they seem not to be compatible with Python 3.
When running 'python setup.py test', setup.py will run 2to3.py on the tests
for you. Did that happen ?
If not, the tests, as they are, are only compatible with python2.
Andi..
… This patch fixes a first set of error:
```
From d5a0a92b58e8df63f756030512453446f00256c5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= ***@***.***>
Date: Wed, 15 Mar 2017 23:08:44 +0100
Subject: [PATCH] Fix `except` syntax error with Python 3.6
---
test/test_LayoutEngine.py | 2 +-
test/test_LocaleData.py | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/test/test_LayoutEngine.py b/test/test_LayoutEngine.py
index 083a082..ed9e8ff 100644
--- a/test/test_LayoutEngine.py
+++ b/test/test_LayoutEngine.py
@@ -31,7 +31,7 @@ try:
if ICU_VERSION >= '58':
raise NotImplementedError
from fontTools.ttLib import TTFont
-except ImportError, e:
+except ImportError:
print >>sys.stderr, "\nfontTools package not found, skipping LayoutEngine tests\n"
except NotImplementedError:
print >>sys.stderr, "\nLayoutEngine not available in ICU %s" %(ICU_VERSION)
diff --git a/test/test_LocaleData.py b/test/test_LocaleData.py
index b4752a2..9d88eba 100644
--- a/test/test_LocaleData.py
+++ b/test/test_LocaleData.py
@@ -184,7 +184,7 @@ class TestLocaleData(TestCase):
try:
print_output(locale + " LocaleDisplayPattern:" + repr(ld.getLocaleDisplayPattern()))
getLocaleDisplayPattern = True
- except ICUError, e: # resource not found
+ except ICUError as e: # resource not found
getLocaleDisplayPattern = str(e) == NOT_FOUND_ERR
except:
getLocaleDisplayPattern = False
@@ -192,7 +192,7 @@ class TestLocaleData(TestCase):
try:
print_output(locale + " LocaleSeparator:" + repr(ld.getLocaleSeparator()))
getLocaleSeparator = True
- except ICUError, e: # resource not found
+ except ICUError as e: # resource not found
getLocaleSeparator = str(e) == NOT_FOUND_ERR
except:
getLocaleSeparator = False
--
2.10.2
```
But then there are some more errors:
```
======================================================================
ERROR: testUnicode (test.test_Charset.TestCharset)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/akien/Mageia/Checkout/python-icu/BUILD/python3-python-icu-1.9.5-1.mga6/test/test_Charset.py", line 62, in testUnicode
ustring = unicode(CharsetDetector(bytes).detect())
NameError: name 'unicode' is not defined
======================================================================
ERROR: testSort (test.test_Collator.TestCollator)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/akien/Mageia/Checkout/python-icu/BUILD/python3-python-icu-1.9.5-1.mga6/test/test_Collator.py", line 47, in testSort
names = [unicode(n.strip(), 'utf-8') for n in input.readlines()]
File "/home/akien/Mageia/Checkout/python-icu/BUILD/python3-python-icu-1.9.5-1.mga6/test/test_Collator.py", line 47, in <listcomp>
names = [unicode(n.strip(), 'utf-8') for n in input.readlines()]
NameError: name 'unicode' is not defined
======================================================================
ERROR: testSurrogatePairs (test.test_Script.TestScript)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/akien/Mageia/Checkout/python-icu/BUILD/python3-python-icu-1.9.5-1.mga6/test/test_Script.py", line 53, in testSurrogatePairs
for i in xrange(pairs.countChar32())]
NameError: name 'xrange' is not defined
======================================================================
ERROR: testPythonTransliterator (test.test_Transliterator.TestTransliterator)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/akien/Mageia/Checkout/python-icu/BUILD/python3-python-icu-1.9.5-1.mga6/test/test_Transliterator.py", line 74, in testPythonTransliterator
self.assertTrue(trans.transliterate(string) == result)
File "/home/akien/Mageia/Checkout/python-icu/BUILD/python3-python-icu-1.9.5-1.mga6/test/test_Transliterator.py", line 64, in handleTransliterate
for i in xrange(pos.start, pos.limit):
NameError: name 'xrange' is not defined
======================================================================
ERROR: testUnicodeString (test.test_Transliterator.TestTransliterator)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/akien/Mageia/Checkout/python-icu/BUILD/python3-python-icu-1.9.5-1.mga6/test/test_Transliterator.py", line 53, in testUnicodeString
self.assertTrue(trans.transliterate(unicode(string)) == result)
NameError: name 'unicode' is not defined
======================================================================
ERROR: testExemplarSet (test.test_LocaleData.TestLocaleData)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/akien/Mageia/Checkout/python-icu/BUILD/python3-python-icu-1.9.5-1.mga6/test/test_LocaleData.py", line 111, in testExemplarSet
print_output(locale + " exemplar " + repr(unicode(exemplarSets[0])))
NameError: name 'unicode' is not defined
======================================================================
ERROR: testExemplarSet2 (test.test_LocaleData.TestLocaleData)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/akien/Mageia/Checkout/python-icu/BUILD/python3-python-icu-1.9.5-1.mga6/test/test_LocaleData.py", line 157, in testExemplarSet2
print_output(locale + " exemplar(ES_STANDARD)" + repr(unicode(exemplarSets[0])))
NameError: name 'unicode' is not defined
----------------------------------------------------------------------
Ran 40 tests in 0.106s
FAILED (errors=7)
```
I don't have time to debug much further just yet, so opening this issue instead of providing a complete PR :)
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
#48
|
It seems to run 2to3 indeed. If I build only the python3 module and run the tests, it works fine, but when I do both the python2 and python3 flavour in different folders, the problem shows up. Might be a quirk of the RPM build environment, I'll investigate this on my end. |
Running the python3 tests before the python2 tests seem to fix the issue. Some voodoo RPM quirks apparently, but not an upstream bug. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I had to disable the tests on the python 3 build of pyicu on Mageia as they seem not to be compatible with Python 3.
This patch fixes a first set of error:
But then there are some more errors:
I don't have time to debug much further just yet, so opening this issue instead of providing a complete PR :)
The text was updated successfully, but these errors were encountered: