[liblouis-liblouisxml] Python2.7 and 3.2 compatible runharness file

Hy,

I sending the runharness.py related modification to this main test script run right under Python2.7 and Python 3.2, because Michael already merged with Python3 and 2.7 bindings.

This patch doesn't resolve the test harness files and example doctest txt files related incompatibility problem the newer Python version, but the modification is need to work this script future with Python 3.2. If future possible fixing louis Python binding the my prewious letter wrote traceback error message if the Python interpreter is 2.7, we I think safe remove the unicode related prefixes from the test harness files and doctest txt example files. In Python 3.2 this prefixes not need because the strings handle the newest version with unicode format by default. I runned all tests in the check directory after I local modified the test harness files and doctests examples, sending the result file. If the python/louis/__init__.py.in file fixed the wrote unicode decode error related traceback with translation functions, I will be sending already saved modified test documents. After this changes the test system will be work both Python 2.7 and 3.2 version.

Attila
Index: tests/runHarness.py
===================================================================
--- tests/runHarness.py (revision 620)
+++ tests/runHarness.py (working copy)
@@ -73,7 +73,7 @@
                         showCurPos(len(actualBRL), actualBRLCursorPos, 
pos2=expectedBRLCursorPos))
         ])
     report.append("--- end ---")
-    print "\n".join(report).encode("utf-8")
+    print(("\n".join(report).encode("utf-8")))
 
 total_failed = 0
 harness_dir = "harness"
@@ -97,13 +97,13 @@
 for harness in iglob(harness_dir + '/*_harness.py'):
     try:
         harnessModule = __import__(basename(harness)[:-3])
-    except Exception, e:
+    except Exception as e:
         # Doesn't look like the harness is a valid python file.
-        print "Warning: could not import %s" % harness
-        print e
+        print("Warning: could not import %s" % harness)
+        print(e)
         total_failed += 1
         continue
-    print "Processing %s" %harness
+    print("Processing %s" %harness)
     failed = 0
     tableList = [harnessModule.table]
     for test in harnessModule.tests:
@@ -118,6 +118,6 @@
             failed += 1 
             reportFailure(text, actualBRL, expectedBRL, cursorPos, 
actualBRLCursorPos, expectedBRLCursorPos)
     total_failed += failed
-    print "%d of %d tests failed." %(failed, len(harnessModule.tests))
+    print("%d of %d tests failed." %(failed, len(harnessModule.tests)))
 
 sys.exit(0 if total_failed == 0 else 1)

Making check in tables
make[1]: Entering directory `/usr/src/liblouis/liblouis2/liblouis/tests/tables'
make[1]: Nothing to be done for `check'.
make[1]: Leaving directory `/usr/src/liblouis/liblouis2/liblouis/tests/tables'
Making check in doctests
make[1]: Entering directory 
`/usr/src/liblouis/liblouis2/liblouis/tests/doctests'
make[1]: Nothing to be done for `check'.
make[1]: Leaving directory `/usr/src/liblouis/liblouis2/liblouis/tests/doctests'
Making check in harness
make[1]: Entering directory `/usr/src/liblouis/liblouis2/liblouis/tests/harness'
make  en-GB-g2_harness.py hu1_harness.py letterDefTest_harness.py
make[2]: Entering directory `/usr/src/liblouis/liblouis2/liblouis/tests/harness'
make[2]: Nothing to be done for `en-GB-g2_harness.py'.
make[2]: Nothing to be done for `hu1_harness.py'.
make[2]: Nothing to be done for `letterDefTest_harness.py'.
make[2]: Leaving directory `/usr/src/liblouis/liblouis2/liblouis/tests/harness'
make[1]: Leaving directory `/usr/src/liblouis/liblouis2/liblouis/tests/harness'
make[1]: Entering directory `/usr/src/liblouis/liblouis2/liblouis/tests'
make  pass2 pass2_inpos inpos inpos_match_replace uplow_with_unicode 
present_progressive capitalized_word capitalized_with_sentance inpos_compbrl 
lastworditalafter en_gb_g1_italics letterDefTest \
          check_all_tables.pl check_endless_loop.pl multiple_table_path.pl 
check_doctests.py runHarness.py
make[2]: Entering directory `/usr/src/liblouis/liblouis2/liblouis/tests'
make[2]: `pass2' is up to date.
make[2]: `pass2_inpos' is up to date.
make[2]: `inpos' is up to date.
make[2]: `inpos_match_replace' is up to date.
make[2]: `uplow_with_unicode' is up to date.
make[2]: `present_progressive' is up to date.
make[2]: `capitalized_word' is up to date.
make[2]: `capitalized_with_sentance' is up to date.
make[2]: `inpos_compbrl' is up to date.
make[2]: `lastworditalafter' is up to date.
make[2]: `en_gb_g1_italics' is up to date.
make[2]: `letterDefTest' is up to date.
make[2]: Nothing to be done for `check_all_tables.pl'.
make[2]: Nothing to be done for `check_endless_loop.pl'.
make[2]: Nothing to be done for `multiple_table_path.pl'.
make[2]: Nothing to be done for `check_doctests.py'.
make[2]: Nothing to be done for `runHarness.py'.
make[2]: Leaving directory `/usr/src/liblouis/liblouis2/liblouis/tests'
make  check-TESTS
make[2]: Entering directory `/usr/src/liblouis/liblouis2/liblouis/tests'
PASS: pass2
PASS: pass2_inpos
PASS: inpos
PASS: inpos_match_replace
Expected: g^
Received: gro^
Diff: Expected '^' but recieved 'r' in index 1
FAIL: uplow_with_unicode
string='greetings  ' cursor=10 (' ') expected=8 recieved=7 (' ')
XFAIL: present_progressive
PASS: capitalized_word
PASS: capitalized_with_sentance
PASS: inpos_compbrl
Expected: .,he sd x wasn't .alw ."w+ z expect$4
Received: .,he sd x wasn't .alw .work+ z expect$4
Diff: Expected '"' but recieved 'w' in index 23
Expected: _ER SAGTE ES __FUNKTION0RE NI4T', IMMER W0 ERWARTET.
Received: __ER SAGTE ES __FUNKTION0RE _NI4T IMMER W0 ERWARTET.
Diff: Expected 'E' but recieved '_' in index 1
XFAIL: lastworditalafter
Expected: ..,this is a ,test in ,italic4.'
Received: ,this is a ,test in ,italic4.'
Diff: Expected '.' but recieved ',' in index 0
Expected: ,this .is .a ,test
Received: ,this is a.' ,test
Diff: Expected '.' but recieved 'i' in index 6
XFAIL: en_gb_g1_italics
PASS: letterDefTest
PASS: check_all_tables.pl
PASS: check_endless_loop.pl
PASS: multiple_table_path.pl
PASS: check_doctests.py
Processing ../tests/harness/en-GB-g2_harness.py
0 of 3 tests failed.
Processing ../tests/harness/hu1_harness.py
0 of 776 tests failed.
Processing ../tests/harness/letterDefTest_harness.py
0 of 1 tests failed.
PASS: runHarness.py
=============================================
1 of 17 tests failed
Please report to john.boyer@xxxxxxxxxxxxxxxxx
=============================================
make[2]: Leaving directory `/usr/src/liblouis/liblouis2/liblouis/tests'
make[1]: Leaving directory `/usr/src/liblouis/liblouis2/liblouis/tests'

Other related posts: