bpo-36019: Use pythontest.net instead of example.com#11941
Conversation
|
Can you add a NEWS entry? |
Sorry, something went wrong.
|
Sure but only when my PR won’t be in WIP. Thanks 🙏 |
Sorry, something went wrong.
eamanu
left a comment
There was a problem hiding this comment.
Great!. It would be great use https on the future :-)
Sorry, something went wrong.
Wait, some tests must not use HTTPS but HTTP. Some tests are written to explicitly test cleartext HTTP (tcp/80). Right now, it seems like: pythontest.net does't redirect to HTTP. Maybe we should use a constant to test.support for HTTP-only URL. |
Sorry, something went wrong.
|
@vstinner like that? and where |
Sorry, something went wrong.
|
There is no need for HTTPS yet. |
Sorry, something went wrong.
|
"`from test.support import TEST_HTTP_URL" LGTM. Maybe just add a short comment where you define the constant to explain the purpose of this URL. I understood that it must be a public HTTP server, it must use HTTP (not HTTPS), and it must support at least GET verb. |
Sorry, something went wrong.
|
ok, I am going to add this "constant" in |
Sorry, something went wrong.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
Sorry, something went wrong.
vstinner
left a comment
There was a problem hiding this comment.
It seems like you misunderstood what I proposed. The idea of a constant is to adding a constant is to allow to use a different URL without having to update tests. Without your current change, if I modify TEST_HTTP_URL to point to google.com, example.com, etc. A lot of tests fail.
Please restrict the change example.com, and only example.com : https://bugs.python.org/issue36019
Sorry, something went wrong.
vstinner
left a comment
There was a problem hiding this comment.
Another request for testURLread().
I blocked connections to example.com using:
# I added example.com to localhost
$ sudo head /etc/hosts
127.0.0.1 apu localhost localhost.localdomain localhost4 localhost4.localdomain4 example.com
::1 apu localhost localhost.localdomain localhost6 localhost6.localdomain6 example.com
$ host example.com
example.com has address 93.184.216.34
example.com has IPv6 address 2606:2800:220:1:248:1893:25c8:1946
# Reject all connections to example.com
$ sudo iptables -A OUTPUT -d 93.184.216.34 -j REJECT
$ sudo ip6tables -A OUTPUT -d 2606:2800:220:1:248:1893:25c8:1946 -j REJECT
And I modified transient_internet() to get an error:
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
index b442070b35..674195e442 100644
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -1483,22 +1483,8 @@ def transient_internet(resource_name, *, timeout=30.0, errnos=()):
"""Return a context manager that raises ResourceDenied when various issues
with the Internet connection manifest themselves as exceptions."""
default_errnos = [
- ('ECONNREFUSED', 111),
- ('ECONNRESET', 104),
- ('EHOSTUNREACH', 113),
- ('ENETUNREACH', 101),
- ('ETIMEDOUT', 110),
- # socket.create_connection() fails randomly with
- # EADDRNOTAVAIL on Travis CI.
- ('EADDRNOTAVAIL', 99),
]
default_gai_errnos = [
- ('EAI_AGAIN', -3),
- ('EAI_FAIL', -4),
- ('EAI_NONAME', -2),
- ('EAI_NODATA', -5),
- # Encountered when trying to resolve IPv6-only hostnames
- ('WSANO_DATA', 11004),
]
denied = ResourceDenied("Resource %r is not available" % resource_name)
Only test_timeout failed because of my patch. So it's good.
Sorry, something went wrong.
vstinner
left a comment
There was a problem hiding this comment.
LGTM.
Sorry, something went wrong.
|
Thanks @matrixise for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7. |
Sorry, something went wrong.
…pythonGH-11941) (cherry picked from commit a40681d) Co-authored-by: Stéphane Wirtel <stephane@wirtel.be>
GH-12177) Use test_support.TEST_HTTP_URL (pythontest.net) instead of http://www.example.com/.
https://bugs.python.org/issue36019