Index: Lib/test/test_normalization.py =================================================================== --- Lib/test/test_normalization.py (revision 77754) +++ Lib/test/test_normalization.py (working copy) @@ -9,12 +9,9 @@ TESTDATAFILE = "NormalizationTest" + os.extsep + "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 @@ 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() Index: Lib/test/test_support.py =================================================================== --- Lib/test/test_support.py (revision 77754) +++ Lib/test/test_support.py (working copy) @@ -438,7 +438,7 @@ testcase.assertRaises(SyntaxError, compile, statement, '', 'exec') -def open_urlresource(url): +def open_urlresource(url, check=lambda f: True): import urlparse, urllib2 requires('urlfetch') @@ -446,7 +446,12 @@ fn = os.path.join(os.path.dirname(__file__), "data", filename) if os.path.exists(fn): - return open(fn) + f = open(fn) + if check(f): + f.seek(0) + return f + f.close() + unlink(fn) print >> get_original_stdout(), '\tfetching %s ...' % url f = urllib2.urlopen(url, timeout=15)