mirror of
https://github.com/python/cpython.git
synced 2025-07-28 21:55:21 +00:00
Use this feature to fix test_normalization.
This commit is contained in:
parent
fae23dc9dc
commit
3cc8f211ed
3 changed files with 37 additions and 13 deletions
|
@ -6,15 +6,12 @@ import sys
|
|||
import os
|
||||
from unicodedata import normalize, unidata_version
|
||||
|
||||
TESTDATAFILE = "NormalizationTest" + os.extsep + "txt"
|
||||
TESTDATAFILE = "NormalizationTest.txt"
|
||||
TESTDATAURL = "http://www.unicode.org/Public/" + unidata_version + "/ucd/" + TESTDATAFILE
|
||||
|
||||
if os.path.exists(TESTDATAFILE):
|
||||
f = open(TESTDATAFILE)
|
||||
l = f.readline()
|
||||
f.close()
|
||||
if not unidata_version in l:
|
||||
os.unlink(TESTDATAFILE)
|
||||
def check_version(testfile):
|
||||
hdr = testfile.readline()
|
||||
return unidata_version in hdr
|
||||
|
||||
class RangeError(Exception):
|
||||
pass
|
||||
|
@ -40,13 +37,14 @@ def unistr(data):
|
|||
|
||||
class NormalizationTest(unittest.TestCase):
|
||||
def test_main(self):
|
||||
part = None
|
||||
part1_data = {}
|
||||
# Hit the exception early
|
||||
try:
|
||||
open_urlresource(TESTDATAURL)
|
||||
testdata = open_urlresource(TESTDATAURL, check_version)
|
||||
except (IOError, HTTPException):
|
||||
self.skipTest("Could not retrieve " + TESTDATAURL)
|
||||
for line in open_urlresource(TESTDATAURL):
|
||||
for line in testdata:
|
||||
if '#' in line:
|
||||
line = line.split('#')[0]
|
||||
line = line.strip()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue