summaryrefslogtreecommitdiff
path: root/Lib/test/test_normalization.py
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2010-03-19 14:25:03 +0000
committerFlorent Xicluna <florent.xicluna@gmail.com>2010-03-19 14:25:03 +0000
commitb69cf8bad70ddeaf53a8fdf9bd6b51eee8539e82 (patch)
tree296bbbcf39b9db1721dc77d0a483bc5495449e1c /Lib/test/test_normalization.py
parentae19416bbf9866f25491e22d98d6baf4d7941739 (diff)
downloadcpython-b69cf8bad70ddeaf53a8fdf9bd6b51eee8539e82.tar.gz
Merged revisions 78982,78986 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r78982 | florent.xicluna | 2010-03-15 15:00:58 +0100 (lun, 15 mar 2010) | 2 lines Remove py3k deprecation warnings from these Unicode tools. ........ r78986 | florent.xicluna | 2010-03-15 19:08:58 +0100 (lun, 15 mar 2010) | 3 lines Issue #7783 and #7787: open_urlresource invalidates the outdated files from the local cache. Use this feature to fix test_normalization. ........
Diffstat (limited to 'Lib/test/test_normalization.py')
-rw-r--r--Lib/test/test_normalization.py17
1 files changed, 7 insertions, 10 deletions
diff --git a/Lib/test/test_normalization.py b/Lib/test/test_normalization.py
index 19fe48d731..13219e70df 100644
--- a/Lib/test/test_normalization.py
+++ b/Lib/test/test_normalization.py
@@ -9,14 +9,9 @@ from unicodedata import normalize, unidata_version
TESTDATAFILE = "NormalizationTest.txt"
TESTDATAURL = "http://www.unicode.org/Public/" + unidata_version + "/ucd/" + TESTDATAFILE
-# Verify we have the correct version of the test data file.
-TESTDATAPATH = os.path.join(os.path.dirname(__file__), "data", TESTDATAFILE)
-if os.path.exists(TESTDATAPATH):
- f = open(TESTDATAPATH, encoding='utf-8')
- 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
@@ -42,13 +37,15 @@ def unistr(data):
class NormalizationTest(unittest.TestCase):
def test_main(self):
+ part = None
part1_data = {}
# Hit the exception early
try:
- open_urlresource(TESTDATAURL, encoding="utf-8")
+ testdata = open_urlresource(TESTDATAURL, encoding="utf-8",
+ check=check_version)
except (IOError, HTTPException):
self.skipTest("Could not retrieve " + TESTDATAURL)
- for line in open_urlresource(TESTDATAURL, encoding="utf-8"):
+ for line in testdata:
if '#' in line:
line = line.split('#')[0]
line = line.strip()