diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2011-03-25 14:25:36 +0200 |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2011-03-25 14:25:36 +0200 |
commit | 923a71c65f6be3e64f520ffab2d213714e563ca8 (patch) | |
tree | c6e567fa2bc5deb47db16f5f784d4068b23ab0d9 /Lib/test/test_normalization.py | |
parent | cf694eaed00e0aff04efa1cd4206bf802af27d6d (diff) | |
parent | 9835e7067415d95345d77f28619897213ba0f775 (diff) | |
download | cpython-923a71c65f6be3e64f520ffab2d213714e563ca8.tar.gz |
#2650: Merge with 3.1.
Diffstat (limited to 'Lib/test/test_normalization.py')
-rw-r--r-- | Lib/test/test_normalization.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/Lib/test/test_normalization.py b/Lib/test/test_normalization.py index b6743712a7..e3e2560356 100644 --- a/Lib/test/test_normalization.py +++ b/Lib/test/test_normalization.py @@ -1,6 +1,7 @@ from test.support import run_unittest, open_urlresource import unittest +from http.client import HTTPException import sys import os from unicodedata import normalize, unidata_version @@ -8,12 +9,9 @@ from unicodedata import normalize, unidata_version TESTDATAFILE = "NormalizationTest.txt" TESTDATAURL = "http://www.unicode.org/Public/" + unidata_version + "/ucd/" + TESTDATAFILE -if os.path.exists(TESTDATAFILE): - f = open(TESTDATAFILE, 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 @@ -39,13 +37,16 @@ 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") - except IOError: + 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"): + self.addCleanup(testdata.close) + for line in testdata: if '#' in line: line = line.split('#')[0] line = line.strip() |