]> granicus.if.org Git - python/commitdiff
Make test_normalization verify the version of the correct test data file.
authorAlexandre Vassalotti <alexandre@peadrop.com>
Wed, 22 Jul 2009 00:30:24 +0000 (00:30 +0000)
committerAlexandre Vassalotti <alexandre@peadrop.com>
Wed, 22 Jul 2009 00:30:24 +0000 (00:30 +0000)
Lib/test/test_normalization.py

index f92a7144861b606353a6fc5c708091d17a468fb4..94d65b89dd506e568880685b176cde28a78f8cc7 100644 (file)
@@ -8,12 +8,14 @@ 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')
+# 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)
+        os.unlink(testdatafile)
 
 class RangeError(Exception):
     pass
@@ -95,7 +97,7 @@ class NormalizationTest(unittest.TestCase):
 
 
 def test_main():
-    # Hit the exception early
+    # Skip the test early if the 'urlfetch' resource is not enabled.
     open_urlresource(TESTDATAURL)
     run_unittest(NormalizationTest)