F841 Local variable assigned to but never used.
MODIFY
test/benchmark.py
test/benchmark.py
@@ -39,7 +39,7 @@ def urllib_get(url_list):
assert url_list
for url in url_list:
now = time.time()
- r = urllib.urlopen(url)
+ urllib.urlopen(url)
elapsed = time.time() - now
print("Got in %0.3f: %s" % (elapsed, url))
@@ -49,7 +49,7 @@ def pool_get(url_list):
pool = urllib3.PoolManager()
for url in url_list:
now = time.time()
- r = pool.request('GET', url, assert_same_host=False)
+ pool.request('GET', url, assert_same_host=False)
elapsed = time.time() - now
print("Got in %0.3fs: %s" % (elapsed, url))

MODIFY
test/contrib/test_pyopenssl_dependencies.py
test/contrib/test_pyopenssl_dependencies.py
@@ -37,7 +37,7 @@ class TestPyOpenSSLInjection(unittest.TestCase):
try:
return_val = Mock()
del return_val._x509
- with patch("OpenSSL.crypto.X509", return_value=return_val) as mock:
+ with patch("OpenSSL.crypto.X509", return_value=return_val):
self.assertRaises(ImportError, inject_into_urllib3)
finally:
# `inject_into_urllib3` is not supposed to succeed.

MODIFY
test/test_compatibility.py
test/test_compatibility.py
@@ -10,7 +10,7 @@ class TestVersionCompatibility(unittest.TestCase):
warnings.simplefilter("always")
# strict=True is deprecated in Py33+
- conn = HTTPConnection('localhost', 12345, strict=True)
+ HTTPConnection('localhost', 12345, strict=True)
if w:
self.fail('HTTPConnection raised warning on strict=True: %r' % w[0].message)
@@ -18,6 +18,6 @@ class TestVersionCompatibility(unittest.TestCase):
def test_connection_source_address(self):
try:
# source_address does not exist in Py26-
- conn = HTTPConnection('localhost', 12345, source_address='127.0.0.1')
+ HTTPConnection('localhost', 12345, source_address='127.0.0.1')
except TypeError as e:
self.fail('HTTPConnection raised TypeError on source_adddress: %r' % e)

MODIFY
test/test_queue_monkeypatch.py
test/test_queue_monkeypatch.py
@@ -23,7 +23,7 @@ class TestMonkeypatchResistance(unittest.TestCase):
def test_queue_monkeypatching(self):
with mock.patch.object(queue, 'Empty', BadError):
http = urllib3.HTTPConnectionPool(host="localhost", block=True)
- first_conn = http._get_conn(timeout=1)
+ http._get_conn(timeout=1)
self.assertRaises(EmptyPoolError, http._get_conn, timeout=1)

MODIFY
test/with_dummyserver/test_chunked_transfer.py
test/with_dummyserver/test_chunked_transfer.py
@@ -28,7 +28,7 @@ class TestChunkedTransfer(SocketDummyServerTestCase):
self.start_chunked_handler()
chunks = ['foo', 'bar', '', 'bazzzzzzzzzzzzzzzzzzzzzz']
pool = HTTPConnectionPool(self.host, self.port, retries=False)
- r = pool.urlopen('GET', '/', chunks, headers=dict(DNT='1'), chunked=True)
+ pool.urlopen('GET', '/', chunks, headers=dict(DNT='1'), chunked=True)
self.assertTrue(b'Transfer-Encoding' in self.buffer)
body = self.buffer.split(b'\r\n\r\n', 1)[1]
@@ -42,7 +42,7 @@ class TestChunkedTransfer(SocketDummyServerTestCase):
def _test_body(self, data):
self.start_chunked_handler()
pool = HTTPConnectionPool(self.host, self.port, retries=False)
- r = pool.urlopen('GET', '/', data, chunked=True)
+ pool.urlopen('GET', '/', data, chunked=True)
header, body = self.buffer.split(b'\r\n\r\n', 1)
self.assertTrue(b'Transfer-Encoding: chunked' in header.split(b'\r\n'))

MODIFY
test/with_dummyserver/test_connectionpool.py
test/with_dummyserver/test_connectionpool.py
@@ -923,7 +923,7 @@ class TestFileBodiesOnRetryOrRedirect(HTTPDummyServerTestCase):
# which is unsupported by BytesIO.
headers = {'Content-Length': '8'}
try:
- resp = self.pool.urlopen('PUT', url, headers=headers, body=body)
+ self.pool.urlopen('PUT', url, headers=headers, body=body)
self.fail('PUT successful despite failed rewind.')
except UnrewindableBodyError as e:
self.assertTrue('Unable to record file position for' in str(e))

MODIFY
test/with_dummyserver/test_proxy_poolmanager.py
test/with_dummyserver/test_proxy_poolmanager.py
@@ -244,19 +244,19 @@ class TestHTTPProxyManager(HTTPDummyProxyTestCase):
http = proxy_from_url(self.proxy_url)
for x in range(2):
- r = http.urlopen('GET', self.http_url)
+ http.urlopen('GET', self.http_url)
self.assertEqual(len(http.pools), 1)
for x in range(2):
- r = http.urlopen('GET', self.http_url_alt)
+ http.urlopen('GET', self.http_url_alt)
self.assertEqual(len(http.pools), 1)
for x in range(2):
- r = http.urlopen('GET', self.https_url)
+ http.urlopen('GET', self.https_url)
self.assertEqual(len(http.pools), 2)
for x in range(2):
- r = http.urlopen('GET', self.https_url_alt)
+ http.urlopen('GET', self.https_url_alt)
self.assertEqual(len(http.pools), 3)
def test_proxy_pooling_ext(self):

F841 Local variable assigned to but never used.