[Python-checkins] python/dist/src/Lib/test regrtest.py,1.104,1.105 test_normalization.py,1.3,1.4
tim_one@users.sourceforge.net
tim_one@users.sourceforge.net
Sun, 24 Nov 2002 10:53:13 -0800
Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv7280/python/Lib/test
Modified Files:
regrtest.py test_normalization.py
Log Message:
Fiddled things so that test_normalization is expected to be skipped if
and only if the test input file doesn't exist.
Index: regrtest.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/regrtest.py,v
retrieving revision 1.104
retrieving revision 1.105
diff -C2 -d -r1.104 -r1.105
*** regrtest.py 24 Nov 2002 02:40:40 -0000 1.104
--- regrtest.py 24 Nov 2002 18:53:11 -0000 1.105
***************
*** 504,507 ****
--- 504,511 ----
# The _ExpectedSkips constructor adds this to the set of expected
# skips if not os.path.supports_unicode_filenames.
+ # test_normalization
+ # Whether a skip is expected here depends on whether a large test
+ # input file has been downloaded. test_normalization.skip_expected
+ # controls that
_expectations = {
***************
*** 529,533 ****
test_mpz
test_nis
- test_normalization
test_openpty
test_poll
--- 533,536 ----
***************
*** 830,839 ****
--- 833,849 ----
def __init__(self):
import os.path
+ from test import test_normalization
+
self.valid = False
if sys.platform in _expectations:
s = _expectations[sys.platform]
self.expected = Set(s.split())
+
if not os.path.supports_unicode_filenames:
self.expected.add('test_pep277')
+
+ if test_normalization.skip_expected:
+ self.expected.add('test_normalization')
+
self.valid = True
Index: test_normalization.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_normalization.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** test_normalization.py 24 Nov 2002 02:37:29 -0000 1.3
--- test_normalization.py 24 Nov 2002 18:53:11 -0000 1.4
***************
*** 1,10 ****
from test.test_support import verbose, TestFailed, TestSkipped, verify
import sys
from unicodedata import normalize
! try:
! data = open("NormalizationTest.txt", "r").readlines()
! except IOError:
! raise TestSkipped("NormalizationTest.txt not found, download from "
! "http://www.unicode.org/Public/UNIDATA/NormalizationTest.txt")
class RangeError:
--- 1,9 ----
from test.test_support import verbose, TestFailed, TestSkipped, verify
import sys
+ import os
from unicodedata import normalize
!
! TESTDATAFILE = "NormalizationTest.txt"
! skip_expected = not os.path.exists(TESTDATAFILE)
class RangeError:
***************
*** 30,68 ****
return u"".join([unichr(x) for x in data])
! part1_data = {}
! for line in data:
! if '#' in line:
! line = line.split('#')[0]
! line = line.strip()
! if not line:
! continue
! if line.startswith("@Part"):
! part = line
! continue
! try:
! c1,c2,c3,c4,c5 = [unistr(x) for x in line.split(';')[:-1]]
! except RangeError:
! # Skip unsupported characters
! continue
! if verbose:
! print line
! # Perform tests
! verify(c2 == NFC(c1) == NFC(c2) == NFC(c3), line)
! verify(c4 == NFC(c4) == NFC(c5), line)
! verify(c3 == NFD(c1) == NFD(c2) == NFD(c3), line)
! verify(c5 == NFD(c4) == NFD(c5), line)
! verify(c4 == NFKC(c1) == NFKC(c2) == NFKC(c3) == NFKC(c4) == NFKC(c5), line)
! verify(c5 == NFKD(c1) == NFKD(c2) == NFKD(c3) == NFKD(c4) == NFKD(c5), line)
! # Record part 1 data
! if part == "@Part1":
! part1_data[c1] = 1
! # Perform tests for all other data
! for c in range(sys.maxunicode+1):
! X = unichr(c)
! if X in part1_data:
! continue
! assert X == NFC(X) == NFD(X) == NFKC(X) == NFKD(X), c
--- 29,79 ----
return u"".join([unichr(x) for x in data])
! def test_main():
! if skip_expected:
! raise TestSkipped(TESTDATAFILE + " not found, download from " +
! "http://www.unicode.org/Public/UNIDATA/" + TESTDATAFILE)
! data = open(TESTDATAFILE).readlines()
! part1_data = {}
! for line in data:
! if '#' in line:
! line = line.split('#')[0]
! line = line.strip()
! if not line:
! continue
! if line.startswith("@Part"):
! part = line
! continue
! try:
! c1,c2,c3,c4,c5 = [unistr(x) for x in line.split(';')[:-1]]
! except RangeError:
! # Skip unsupported characters
! continue
! if verbose:
! print line
! # Perform tests
! verify(c2 == NFC(c1) == NFC(c2) == NFC(c3), line)
! verify(c4 == NFC(c4) == NFC(c5), line)
! verify(c3 == NFD(c1) == NFD(c2) == NFD(c3), line)
! verify(c5 == NFD(c4) == NFD(c5), line)
! verify(c4 == NFKC(c1) == NFKC(c2) == NFKC(c3) == NFKC(c4) == NFKC(c5),
! line)
! verify(c5 == NFKD(c1) == NFKD(c2) == NFKD(c3) == NFKD(c4) == NFKD(c5),
! line)
!
! # Record part 1 data
! if part == "@Part1":
! part1_data[c1] = 1
!
! # Perform tests for all other data
! for c in range(sys.maxunicode+1):
! X = unichr(c)
! if X in part1_data:
! continue
! assert X == NFC(X) == NFD(X) == NFKC(X) == NFKD(X), c
!
! if __name__ == "__main__":
! test_main()