https://github.com/python/cpython/commit/58ccf21cbb92e0e99cbe28f93f1a4a1f09af71ec
commit: 58ccf21cbb92e0e99cbe28f93f1a4a1f09af71ec
branch: main
author: Zachary Ware <[email protected]>
committer: zware <[email protected]>
date: 2026-01-23T15:07:27-06:00
summary:
gh-74902: Avoid hitting unicode.org for test data (GH-144195)
Use our own pythontest.net instead.
files:
M Lib/test/test_unicodedata.py
diff --git a/Lib/test/test_unicodedata.py b/Lib/test/test_unicodedata.py
index f9c0cd20438174..a46ca034f3bfc9 100644
--- a/Lib/test/test_unicodedata.py
+++ b/Lib/test/test_unicodedata.py
@@ -30,6 +30,26 @@ def iterallchars():
maxunicode = 0xffff if quicktest else sys.maxunicode
return map(chr, range(maxunicode + 1))
+
+def check_version(testfile):
+ hdr = testfile.readline()
+ return unicodedata.unidata_version in hdr
+
+
+def download_test_data_file(filename):
+ TESTDATAURL =
f"http://www.pythontest.net/unicode/{unicodedata.unidata_version}/{filename}"
+
+ try:
+ return open_urlresource(TESTDATAURL, encoding="utf-8",
check=check_version)
+ except PermissionError:
+ raise unittest.SkipTest(
+ f"Permission error when downloading {TESTDATAURL} "
+ f"into the test data directory"
+ )
+ except (OSError, HTTPException) as exc:
+ raise unittest.SkipTest(f"Failed to download {TESTDATAURL}: {exc}")
+
+
class UnicodeMethodsTest(unittest.TestCase):
# update this, if the database changes
@@ -956,11 +976,6 @@ def test_segment_object(self):
class NormalizationTest(unittest.TestCase):
- @staticmethod
- def check_version(testfile):
- hdr = testfile.readline()
- return unicodedata.unidata_version in hdr
-
@staticmethod
def unistr(data):
data = [int(x, 16) for x in data.split(" ")]
@@ -970,17 +985,7 @@ def unistr(data):
@requires_resource('cpu')
def test_normalization(self):
TESTDATAFILE = "NormalizationTest.txt"
- TESTDATAURL =
f"http://www.pythontest.net/unicode/{unicodedata.unidata_version}/{TESTDATAFILE}"
-
- # Hit the exception early
- try:
- testdata = open_urlresource(TESTDATAURL, encoding="utf-8",
- check=self.check_version)
- except PermissionError:
- self.skipTest(f"Permission error when downloading {TESTDATAURL} "
- f"into the test data directory")
- except (OSError, HTTPException) as exc:
- self.skipTest(f"Failed to download {TESTDATAURL}: {exc}")
+ testdata = download_test_data_file(TESTDATAFILE)
with testdata:
self.run_normalization_tests(testdata, unicodedata)
@@ -1077,25 +1082,10 @@ class MyStr(str):
class GraphemeBreakTest(unittest.TestCase):
- @staticmethod
- def check_version(testfile):
- hdr = testfile.readline()
- return unicodedata.unidata_version in hdr
-
@requires_resource('network')
def test_grapheme_break(self):
- TESTDATAFILE = "auxiliary/GraphemeBreakTest.txt"
- TESTDATAURL =
f"https://www.unicode.org/Public/{unicodedata.unidata_version}/ucd/{TESTDATAFILE}"
-
- # Hit the exception early
- try:
- testdata = open_urlresource(TESTDATAURL, encoding="utf-8",
- check=self.check_version)
- except PermissionError:
- self.skipTest(f"Permission error when downloading {TESTDATAURL} "
- f"into the test data directory")
- except (OSError, HTTPException) as exc:
- self.skipTest(f"Failed to download {TESTDATAURL}: {exc}")
+ TESTDATAFILE = "GraphemeBreakTest.txt"
+ testdata = download_test_data_file(TESTDATAFILE)
with testdata:
self.run_grapheme_break_tests(testdata)
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]