[liblouis-liblouisxml] Re: A hopefuly solution: if my fix are good, duplicated test harness files not need

  • From: Michael Whapples <mwhapples@xxxxxxx>
  • To: liblouis-liblouisxml@xxxxxxxxxxxxx
  • Date: Thu, 17 May 2012 10:20:14 +0100

PS. While I am tempted to do work now, I feel it may be wise to wait to here comments from others such as Christian, let's see if we have a consensus before putting more work in.


Michael Whapples
On 17/05/2012 10:13, Michael Whapples wrote:
Hello,
I think you get the issue with LetterDefTest because of the difference in how python handles strings and unicode and even if not precisely the reasons such an approach may be setting up for future problems.

The difficulty is that by doing what you suggest means you are defining different things to different versions of python and so making it very hard to handle unicode. I think LetterDefTest uses python source code encoding and uses that to insert the unicode character, I am not sure how python2 handles such a character being inserted as 'x' notation cannot accept unicode characters.

An example of why I say its setting up for issues in the future though. In short one cannot use python unicode escape sequences (IE. \uXXXX notation).

* In python2 one would do u'\u2061'
* In python3 one would do '\u2061'
* If one tried '\u2061' in python2 this does not insert the character but results in the six characters \ u 2 0 6 1.

Above shows different behaviour between python versions and so makes it difficult. This and python version specific code in runharness.py could lead to python version specific failures when bindings work fine on both (IE. false results on one version of python).

As I indicated in a previous message I am preferring b'x'.decode('UTF-8') notation as it works the same for both python2 and python3 and so avoid any python version specific code (no need for any if sys.version_info[0] == 2: checks).

For the above unicode example of \u2061, one has to enter the bytes for the encoding used (NOTE: one could change it to what they want in the decode function call, I will stick with UTF-8).
b'\xe2\x81\xa1'.decode('UTF-8')
Will result in the correct unicode aware type on both python2 (u'\u2061') and python3 ('\u2061').

Michael Whapples
On 17/05/2012 09:29, Hammer Attila wrote:
Hy,

Michael, please look my fix.
I found a hopefuly solution to we prevent need using different test harness files to handle Python2 and Python3 differences. My testing machine all modified test harness tests running good both Python2 and Python3, both in Python interpreters if I run runHarness.py file and when I do a make check command in the tests directory. I simple removed old Python2 test harness files the u' and u" markups, and doed a small modification in runharness.py file.

I only not understanding a test result difference:
If I direct run in any python version with runharness.py file, letterdeftest test harness file producing following result:
Processing harness/letterDefTest_harness.py
--- Braille Difference Failure: ---
text: '⠍⠎'
CursorAt: 0 '^ '
expected brl: '⠎⠍'
actual brl: '⠍⠎'
brlCursorAt: 0 '^ '
--- end ---
1 of 1 tests failed.
The other two test harness files produced right with 0 failures.

When I doing all tests in the test directory with make check command, I see following result:
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
Why have this difference the letterdefs test harness file test result when I running direct with Python the runHarness.py file?

If I doing make check command, following tests is failed:
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
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

I think this failures independent with runHarness.py file modification.
Hopefuly my fix pass the reviewing, because future simplest the test harness files maintenance.

Attila

For a description of the software, to download it and links to
project pages go to http://www.abilitiessoft.com

For a description of the software, to download it and links to
project pages go to http://www.abilitiessoft.com

Other related posts: