summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_normalization.py
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2010-03-15 18:08:58 (GMT)
committerFlorent Xicluna <florent.xicluna@gmail.com>2010-03-15 18:08:58 (GMT)
commit3cc8f211ed0d569836114d0d54c6298a21e6dde3 (patch)
treef3ceb6af8296b5cdb6d4e8860df240db5e208ac0 /Lib/test/test_normalization.py
parentfae23dc9dc1b4e1b3138b1c933306869440408f2 (diff)
downloadcpython-3cc8f211ed0d569836114d0d54c6298a21e6dde3.zip
cpython-3cc8f211ed0d569836114d0d54c6298a21e6dde3.tar.gz
cpython-3cc8f211ed0d569836114d0d54c6298a21e6dde3.tar.bz2
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.py16
1 files changed, 7 insertions, 9 deletions
diff --git a/Lib/test/test_normalization.py b/Lib/test/test_normalization.py
index f9f4f68..2c49720 100644
--- a/Lib/test/test_normalization.py
+++ b/Lib/test/test_normalization.py
@@ -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()