Remove python2 compat stuff from test_socketlevel.py
* Reformat imports in test_socketlevel.py
Make the next commit more understandable.
* Remove python2 compat stuff from test_socketlevel.py
# TODO: Break this module up into pieces. Maybe group by functionality tested
# rather than the socket level-ness of it.
-import http.client as httplib
+import errno
+import os
+import os.path
+import select
+import shutil
+import socket
+import ssl
+import tempfile
+from collections import OrderedDict
+from test import (
+ LONG_TIMEOUT,
+ SHORT_TIMEOUT,
+ notSecureTransport,
+ notWindows,
+ requires_ssl_context_keyfile_password,
+ resolvesLocalhostFQDN,
+)
+from threading import Event
+from unittest import mock
+
+import pytest
+import trustme
from dummyserver.server import (
DEFAULT_CA,
@@ -26,37 +47,6 @@ from urllib3.util.timeout import Timeout
from .. import LogRecorder, has_alpn
-try:
- from mimetools import Message as MimeToolMessage
-except ImportError:
-
- class MimeToolMessage:
- pass
-
-
-import errno
-import os
-import os.path
-import select
-import shutil
-import socket
-import ssl
-import tempfile
-from collections import OrderedDict
-from test import (
- LONG_TIMEOUT,
- SHORT_TIMEOUT,
- notSecureTransport,
- notWindows,
- requires_ssl_context_keyfile_password,
- resolvesLocalhostFQDN,
-)
-from threading import Event
-from unittest import mock
-
-import pytest
-import trustme
-
# Retry failed tests
pytestmark = pytest.mark.flaky
@@ -1616,10 +1606,6 @@ class TestHeaders(SocketDummyServerTestCase):
assert expected_response_headers == actual_response_headers
-@pytest.mark.skipif(
- issubclass(httplib.HTTPMessage, MimeToolMessage),
- reason="Header parsing errors not available",
-)
class TestBrokenHeaders(SocketDummyServerTestCase):
def _test_broken_header_parsing(self, headers, unparsed_data_check=None):
self.start_response_handler(
