E302 Expected 2 blank lines, found 1
MODIFY
test/__init__.py
test/__init__.py
@@ -29,10 +29,12 @@ def clear_warnings(cls=HTTPWarning):
new_filters.append(f)
warnings.filters[:] = new_filters
+
def setUp():
clear_warnings()
warnings.simplefilter('ignore', HTTPWarning)
+
def onlyPy26OrOlder(test):
"""Skips this test unless you are on Python2.6.x or earlier."""
@@ -44,6 +46,7 @@ def onlyPy26OrOlder(test):
return test(*args, **kwargs)
return wrapper
+
def onlyPy27OrNewer(test):
"""Skips this test unless you are on Python 2.7.x or later."""
@@ -55,6 +58,7 @@ def onlyPy27OrNewer(test):
return test(*args, **kwargs)
return wrapper
+
def onlyPy279OrNewer(test):
"""Skips this test unless you are on Python 2.7.9 or later."""
@@ -66,6 +70,7 @@ def onlyPy279OrNewer(test):
return test(*args, **kwargs)
return wrapper
+
def onlyPy2(test):
"""Skips this test unless you are on Python 2.x"""
@@ -77,6 +82,7 @@ def onlyPy2(test):
return test(*args, **kwargs)
return wrapper
+
def onlyPy3(test):
"""Skips this test unless you are on Python3.x"""
@@ -89,6 +95,8 @@ def onlyPy3(test):
return wrapper
_requires_network_has_route = None
+
+
def requires_network(test):
"""Helps you skip tests that require the network"""

MODIFY
test/contrib/test_gae_manager.py
test/contrib/test_gae_manager.py
@@ -196,6 +196,7 @@ class TestGAERetry(TestRetry):
test_retry_redirect_history = None
test_multi_redirect_history = None
+
class TestGAERetryAfter(TestRetryAfter):
__test__ = True

MODIFY
test/contrib/test_pyopenssl_dependencies.py
test/contrib/test_pyopenssl_dependencies.py
@@ -11,6 +11,7 @@ except ImportError as e:
from mock import patch, Mock
+
class TestPyOpenSSLInjection(unittest.TestCase):
"""
Tests for error handling in pyopenssl's 'inject_into urllib3'

MODIFY
test/port_helpers.py
test/port_helpers.py
@@ -9,6 +9,7 @@ import socket
HOST = "127.0.0.1"
HOSTv6 = "::1"
+
def find_unused_port(family=socket.AF_INET, socktype=socket.SOCK_STREAM):
"""Returns an unused port that should be suitable for binding. This is
achieved by creating a temporary socket with the same family and type as
@@ -69,6 +70,7 @@ def find_unused_port(family=socket.AF_INET, socktype=socket.SOCK_STREAM):
del tempsock
return port
+
def bind_port(sock, host=HOST):
"""Bind the socket to a free port and return the port number. Relies on
ephemeral ports in order to ensure we are using an unbound port. This is

MODIFY
test/test_queue_monkeypatch.py
test/test_queue_monkeypatch.py
@@ -7,6 +7,7 @@ import urllib3
from urllib3.exceptions import EmptyPoolError
from urllib3.packages.six.moves import queue
+
class BadError(Exception):
"""
This should not be raised.

MODIFY
test/test_util.py
test/test_util.py
@@ -47,6 +47,7 @@ from . import clear_warnings
# numbers used for timeouts
TIMEOUT_EPOCH = 1000
+
class TestUtil(unittest.TestCase):
def test_get_host(self):
url_host_map = {

MODIFY
test/with_dummyserver/test_connectionpool.py
test/with_dummyserver/test_connectionpool.py
@@ -871,6 +871,7 @@ class TestRetryAfter(HTTPDummyServerTestCase):
self.assertEqual(r.status, 200)
self.assertTrue(delta < 1)
+
class TestFileBodiesOnRetryOrRedirect(HTTPDummyServerTestCase):
def setUp(self):
self.pool = HTTPConnectionPool(self.host, self.port, timeout=0.1)

MODIFY
test/with_dummyserver/test_socketlevel.py
test/with_dummyserver/test_socketlevel.py
@@ -868,6 +868,7 @@ class TestErrorWrapping(SocketDummyServerTestCase):
pool = HTTPConnectionPool(self.host, self.port, retries=False)
self.assertRaises(ProtocolError, pool.request, 'GET', '/')
+
class TestHeaders(SocketDummyServerTestCase):
@onlyPy3
@@ -1090,6 +1091,7 @@ class TestStream(SocketDummyServerTestCase):
done_event.set()
+
class TestBadContentLength(SocketDummyServerTestCase):
def test_enforce_content_length_get(self):
done_event = Event()

E302 Expected 2 blank lines, found 1