-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-41391: Make test_unicodedata pass when running without network #21615
Conversation
I updated the commit message to (hopefully) make the intention clearer by mentioning a related issue https://bugs.python.org/issue29887. |
Someone needs to check one use of support.socket_helper.transient_internet |
open_urlresource() skips the test if the urlfetch resource is disallowed. By default, all resources are enabled. Maybe the default should exclude urlfetch? Or the "network" resource should be reused? https://docs.python.org/dev/library/test.html#test.support.requires |
I'm not sure that the code is wrong. Maybe the error message should explain how to disable the test resource "urlfetch" instead? cc @pablogsal @zware |
Hmm, I think This change LGTM, but I have not actually tested it to confirm my reading of the code. |
Oops, I found that I added description about HTTP 4xx errors to the new commit message but forgot to also update the pull request description. That's done now. I've also checked that 404 errors from the server fails the test. With the following changes on top of my commit (d37115f4b998b2780705f837137865d11a741f64) in this pull request: diff --git a/Lib/test/test_unicodedata.py b/Lib/test/test_unicodedata.py
index 275a2ed747..757011a72c 100644
--- a/Lib/test/test_unicodedata.py
+++ b/Lib/test/test_unicodedata.py
@@ -322,7 +322,7 @@ class NormalizationTest(unittest.TestCase):
def test_normalization(self):
TESTDATAFILE = "NormalizationTest.txt"
- TESTDATAURL = f"http://www.pythontest.net/unicode/{unicodedata.unidata_version}/{TESTDATAFILE}"
+ TESTDATAURL = f"http://www.pythontest.net/does_not_exist.txt"
# Hit the exception early
try: The normalization test fails with: (I tested on Linux instead of Android this time - should be irrelevant)
|
The self.fail() statement below was added to make HTTP 404 error visible [1]. After this patch HTTP 404 still fails the test as transient_internet() does not filter 4xx errors. [1] https://bugs.python.org/issue29887 A sample failure log before patch: 0:05:28 load avg: 1.21 [376/423/11] test_unicodedata failed test test_unicodedata failed -- Traceback (most recent call last): File "/data/local/tmp/lib/python3.10/urllib/request.py", line 1342, in do_open h.request(req.get_method(), req.selector, req.data, headers, socket.gaierror: [Errno 7] No address associated with hostname During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/data/local/tmp/lib/python3.10/test/test_unicodedata.py", line 329, in test_normalization testdata = open_urlresource(TESTDATAURL, encoding="utf-8", urllib.error.URLError: <urlopen error [Errno 7] No address associated with hostname> During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/data/local/tmp/lib/python3.10/test/test_unicodedata.py", line 335, in test_normalization self.fail(f"Could not retrieve {TESTDATAURL}") AssertionError: Could not retrieve http://www.pythontest.net/unicode/13.0.0/NormalizationTest.txt The log is grabbed from an Android emulator running Android 10 x86_64 and testing CPython commit af08db7.
Oops, I didn't notice there is already a simpler fix pushed after I created this pull request: #24650. |
The
self.fail()
statement below was added to make HTTP 404 error visible[1]. After this patch HTTP 404 still fails the test as
transient_internet() does not filter 4xx errors.
[1] https://bugs.python.org/issue29887
A sample failure log before patch:
The log is grabbed from an Android emulator running Android 10 x86_64
and testing CPython commit af08db7.
https://bugs.python.org/issue41391