Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
5d120e95
Commit
5d120e95
authored
Dec 16, 2015
by
Martin Panter
Browse files
Options
Browse Files
Download
Plain Diff
Issue #23788: Merge test_bad_address() cleanup from 3.5
parents
129a4144
a7f9933e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
35 deletions
+20
-35
Lib/test/test_urllib2_localnet.py
Lib/test/test_urllib2_localnet.py
+0
-29
Lib/test/test_urllibnet.py
Lib/test/test_urllibnet.py
+20
-6
No files found.
Lib/test/test_urllib2_localnet.py
View file @
5d120e95
...
...
@@ -626,35 +626,6 @@ class TestUrlopen(unittest.TestCase):
url
=
open_url
.
geturl
()
self
.
assertEqual
(
url
,
"http://localhost:%s"
%
handler
.
port
)
def
test_bad_address
(
self
):
# Make sure proper exception is raised when connecting to a bogus
# address.
# as indicated by the comment below, this might fail with some ISP,
# so we run the test only when -unetwork/-uall is specified to
# mitigate the problem a bit (see #17564)
support
.
requires
(
'network'
)
self
.
assertRaises
(
OSError
,
# Given that both VeriSign and various ISPs have in
# the past or are presently hijacking various invalid
# domain name requests in an attempt to boost traffic
# to their own sites, finding a domain name to use
# for this test is difficult. RFC2606 leads one to
# believe that '.invalid' should work, but experience
# seemed to indicate otherwise. Single character
# TLDs are likely to remain invalid, so this seems to
# be the best choice. The trailing '.' prevents a
# related problem: The normal DNS resolver appends
# the domain names from the search path if there is
# no '.' the end and, and if one of those domains
# implements a '*' rule a result is returned.
# However, none of this will prevent the test from
# failing if the ISP hijacks all invalid domain
# requests. The real solution would be to be able to
# parameterize the framework with a mock resolver.
urllib
.
request
.
urlopen
,
"http://sadflkjsasf.i.nvali.d./"
)
def
test_iteration
(
self
):
expected_response
=
b"pycon 2008..."
handler
=
self
.
start_server
([(
200
,
[],
expected_response
)])
...
...
Lib/test/test_urllibnet.py
View file @
5d120e95
...
...
@@ -113,7 +113,25 @@ class urlopenNetworkTests(unittest.TestCase):
def
test_bad_address
(
self
):
# Make sure proper exception is raised when connecting to a bogus
# address.
bogus_domain
=
"sadflkjsasf.i.nvali.d"
# Given that both VeriSign and various ISPs have in
# the past or are presently hijacking various invalid
# domain name requests in an attempt to boost traffic
# to their own sites, finding a domain name to use
# for this test is difficult. RFC2606 leads one to
# believe that '.invalid' should work, but experience
# seemed to indicate otherwise. Single character
# TLDs are likely to remain invalid, so this seems to
# be the best choice. The trailing '.' prevents a
# related problem: The normal DNS resolver appends
# the domain names from the search path if there is
# no '.' the end and, and if one of those domains
# implements a '*' rule a result is returned.
# However, none of this will prevent the test from
# failing if the ISP hijacks all invalid domain
# requests. The real solution would be to be able to
# parameterize the framework with a mock resolver.
bogus_domain
=
"sadflkjsasf.i.nvali.d."
try
:
socket
.
gethostbyname
(
bogus_domain
)
except
OSError
:
...
...
@@ -128,11 +146,7 @@ class urlopenNetworkTests(unittest.TestCase):
'can be caused by a broken DNS server '
'(e.g. returns 404 or hijacks page)'
)
with
self
.
assertRaises
(
OSError
,
msg
=
failure_explanation
):
# SF patch 809915: In Sep 2003, VeriSign started highjacking
# invalid .com and .net addresses to boost traffic to their own
# site. This test started failing then. One hopes the .invalid
# domain will be spared to serve its defined purpose.
urllib
.
request
.
urlopen
(
"http://sadflkjsasf.i.nvali.d/"
)
urllib
.
request
.
urlopen
(
"http://{}/"
.
format
(
bogus_domain
))
class
urlretrieveNetworkTests
(
unittest
.
TestCase
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment