Mailgun: disable non-ASCII attachment filename workaround when not needed

urllib3 v1.25 fixes non-ASCII filenames in multipart form data to be
RFC 5758 compliant by default, so our earlier workaround is no longer
needed. Disable the workaround if we detect that Requests is using a
fixed version of urllib3.

Closes #157
This commit is contained in:
Mike Edmunds
2019-09-03 18:04:27 -07:00
committed by GitHub
parent df29ee2da6
commit fd558e904e
6 changed files with 55 additions and 5 deletions

View File

@@ -115,6 +115,13 @@ class RequestsBackendMockAPITestCase(SimpleTestCase, AnymailTestMixin):
"""Returns the auth sent to the mock ESP API"""
return self.get_api_call_arg('auth', required)
def get_api_prepared_request(self):
"""Returns the PreparedRequest that would have been sent"""
(args, kwargs) = self.mock_request.call_args
kwargs.pop('timeout', None) # Session-only param
request = requests.Request(**kwargs)
return request.prepare()
def assert_esp_not_called(self, msg=None):
if self.mock_request.called:
raise AssertionError(msg or "ESP API was called and shouldn't have been")