mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
Remove newlines from test_urllib2_localnet.py
This commit is contained in:
18
Lib/test/test_urllib2_localnet.py
vendored
18
Lib/test/test_urllib2_localnet.py
vendored
@@ -360,7 +360,6 @@ class ProxyAuthTests(unittest.TestCase):
|
||||
self.server.stop()
|
||||
self.server = None
|
||||
|
||||
|
||||
def test_proxy_with_bad_password_raises_httperror(self):
|
||||
self.proxy_digest_handler.add_password(self.REALM, self.URL,
|
||||
self.USER, self.PASSWD+"bad")
|
||||
@@ -369,7 +368,6 @@ class ProxyAuthTests(unittest.TestCase):
|
||||
self.opener.open(self.URL)
|
||||
cm.exception.close()
|
||||
|
||||
|
||||
def test_proxy_with_no_password_raises_httperror(self):
|
||||
self.digest_auth_handler.set_qop("auth")
|
||||
with self.assertRaises(urllib.error.HTTPError) as cm:
|
||||
@@ -384,7 +382,6 @@ class ProxyAuthTests(unittest.TestCase):
|
||||
while result.read():
|
||||
pass
|
||||
|
||||
|
||||
def test_proxy_qop_auth_int_works_or_throws_urlerror(self):
|
||||
self.proxy_digest_handler.add_password(self.REALM, self.URL,
|
||||
self.USER, self.PASSWD)
|
||||
@@ -509,7 +506,6 @@ class TestUrlopen(unittest.TestCase):
|
||||
handler.port = server.port
|
||||
return handler
|
||||
|
||||
|
||||
def test_redirection(self):
|
||||
expected_response = b"We got here..."
|
||||
responses = [
|
||||
@@ -523,7 +519,6 @@ class TestUrlopen(unittest.TestCase):
|
||||
self.assertEqual(data, expected_response)
|
||||
self.assertEqual(handler.requests, ["/", "/somewhere_else"])
|
||||
|
||||
|
||||
def test_chunked(self):
|
||||
expected_response = b"hello world"
|
||||
chunked_start = (
|
||||
@@ -538,7 +533,6 @@ class TestUrlopen(unittest.TestCase):
|
||||
data = self.urlopen("http://localhost:%s/" % handler.port)
|
||||
self.assertEqual(data, expected_response)
|
||||
|
||||
|
||||
def test_404(self):
|
||||
expected_response = b"Bad bad bad..."
|
||||
handler = self.start_server([(404, [], expected_response)])
|
||||
@@ -554,7 +548,6 @@ class TestUrlopen(unittest.TestCase):
|
||||
self.assertEqual(data, expected_response)
|
||||
self.assertEqual(handler.requests, ["/weeble"])
|
||||
|
||||
|
||||
def test_200(self):
|
||||
expected_response = b"pycon 2008..."
|
||||
handler = self.start_server([(200, [], expected_response)])
|
||||
@@ -562,7 +555,6 @@ class TestUrlopen(unittest.TestCase):
|
||||
self.assertEqual(data, expected_response)
|
||||
self.assertEqual(handler.requests, ["/bizarre"])
|
||||
|
||||
|
||||
def test_200_with_parameters(self):
|
||||
expected_response = b"pycon 2008..."
|
||||
handler = self.start_server([(200, [], expected_response)])
|
||||
@@ -571,14 +563,12 @@ class TestUrlopen(unittest.TestCase):
|
||||
self.assertEqual(data, expected_response)
|
||||
self.assertEqual(handler.requests, ["/bizarre", b"get=with_feeling"])
|
||||
|
||||
|
||||
def test_https(self):
|
||||
handler = self.start_https_server()
|
||||
context = ssl.create_default_context(cafile=CERT_localhost)
|
||||
data = self.urlopen("https://localhost:%s/bizarre" % handler.port, context=context)
|
||||
self.assertEqual(data, b"we care a bit")
|
||||
|
||||
|
||||
def test_https_sni(self):
|
||||
if ssl is None:
|
||||
self.skipTest("ssl module required")
|
||||
@@ -595,7 +585,6 @@ class TestUrlopen(unittest.TestCase):
|
||||
self.urlopen("https://localhost:%s" % handler.port, context=context)
|
||||
self.assertEqual(sni_name, "localhost")
|
||||
|
||||
|
||||
def test_sending_headers(self):
|
||||
handler = self.start_server()
|
||||
req = urllib.request.Request("http://localhost:%s/" % handler.port,
|
||||
@@ -604,7 +593,6 @@ class TestUrlopen(unittest.TestCase):
|
||||
pass
|
||||
self.assertEqual(handler.headers_received["Range"], "bytes=20-39")
|
||||
|
||||
|
||||
def test_sending_headers_camel(self):
|
||||
handler = self.start_server()
|
||||
req = urllib.request.Request("http://localhost:%s/" % handler.port,
|
||||
@@ -614,7 +602,6 @@ class TestUrlopen(unittest.TestCase):
|
||||
self.assertIn("X-Some-Header", handler.headers_received.keys())
|
||||
self.assertNotIn("X-SoMe-hEader", handler.headers_received.keys())
|
||||
|
||||
|
||||
def test_basic(self):
|
||||
handler = self.start_server()
|
||||
with urllib.request.urlopen("http://localhost:%s" % handler.port) as open_url:
|
||||
@@ -622,7 +609,6 @@ class TestUrlopen(unittest.TestCase):
|
||||
self.assertHasAttr(open_url, attr)
|
||||
self.assertTrue(open_url.read(), "calling 'read' failed")
|
||||
|
||||
|
||||
def test_info(self):
|
||||
handler = self.start_server()
|
||||
open_url = urllib.request.urlopen(
|
||||
@@ -634,7 +620,6 @@ class TestUrlopen(unittest.TestCase):
|
||||
"instance of email.message.Message")
|
||||
self.assertEqual(info_obj.get_content_subtype(), "plain")
|
||||
|
||||
|
||||
def test_geturl(self):
|
||||
# Make sure same URL as opened is returned by geturl.
|
||||
handler = self.start_server()
|
||||
@@ -643,7 +628,6 @@ class TestUrlopen(unittest.TestCase):
|
||||
url = open_url.geturl()
|
||||
self.assertEqual(url, "http://localhost:%s" % handler.port)
|
||||
|
||||
|
||||
def test_iteration(self):
|
||||
expected_response = b"pycon 2008..."
|
||||
handler = self.start_server([(200, [], expected_response)])
|
||||
@@ -651,7 +635,6 @@ class TestUrlopen(unittest.TestCase):
|
||||
for line in data:
|
||||
self.assertEqual(line, expected_response)
|
||||
|
||||
|
||||
def test_line_iteration(self):
|
||||
lines = [b"We\n", b"got\n", b"here\n", b"verylong " * 8192 + b"\n"]
|
||||
expected_response = b"".join(lines)
|
||||
@@ -664,7 +647,6 @@ class TestUrlopen(unittest.TestCase):
|
||||
(index, len(lines[index]), len(line)))
|
||||
self.assertEqual(index + 1, len(lines))
|
||||
|
||||
|
||||
def test_issue16464(self):
|
||||
# See https://bugs.python.org/issue16464
|
||||
# and https://bugs.python.org/issue46648
|
||||
|
||||
Reference in New Issue
Block a user