Skip to content

Commit

Permalink
Update in response to review
Browse files Browse the repository at this point in the history
  • Loading branch information
sg3-141-592 committed Jun 8, 2023
1 parent 5aa78bb commit aa2c9ea
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
8 changes: 3 additions & 5 deletions src/urllib3/request.py
Expand Up @@ -131,7 +131,7 @@ def request_encode_body(
'fakefile': ('foofile.txt', 'contents of foofile'),
'realfile': ('barfile.txt', open('realfile').read()),
'typedfile': ('bazfile.bin', open('bazfile').read(),
'image/jpeg'),
'image/jpeg'),
'nonamefile': 'contents of nonamefile field',
}
Expand Down Expand Up @@ -182,11 +182,9 @@ def __call__(self, *args, **kwargs):
suggesting they may need urllib3 v2
"""
raise TypeError(
"TypeError: 'module' object is not callable\n"
"urllib3.requests() method is not supported in this release, "
"'module' object is not callable\n"
"urllib3.request() method is not supported in this release, "
"upgrade to urllib3 v2 to use it"
)

RequestMethods = RequestMethods

sys.modules[__name__].__class__ = RequestModule
10 changes: 7 additions & 3 deletions test/test_request.py
@@ -1,5 +1,6 @@
import pytest
import six
import types

import urllib3

Expand All @@ -16,6 +17,9 @@ def test_request_import_error(self):
urllib3.request(1, a=2)
assert "urllib3 v2" in exc_info.value.args[0]

def test_request_method_import(self):
"""Ensure that * method imports are not broken by this change"""
from urllib3.request import urlencode # noqa: F401
def test_request_module_properties(self):
"""Ensure properties of the overridden request module
are still present"""
assert isinstance(urllib3.request, types.ModuleType)
expected_attrs = {"RequestMethods", 'encode_multipart_formdata', 'urlencode'}
assert set(dir(urllib3.request)).issuperset(expected_attrs)

0 comments on commit aa2c9ea

Please sign in to comment.