Cleanup: Avoid Python 3.7 deprecation warning on 'async' keyword

Fixes #92
This commit is contained in:
medmunds
2018-02-26 10:24:08 -08:00
parent dc2b4b4e7a
commit ec0ee336a2
2 changed files with 8 additions and 3 deletions

View File

@@ -252,9 +252,9 @@ class MandrillPayload(RequestsPayload):
('template_content', combine, None),
)
def set_async(self, async):
def set_async(self, is_async):
self.deprecated_to_esp_extra('async')
self.esp_extra['async'] = async
self.esp_extra['async'] = is_async
def set_ip_pool(self, ip_pool):
self.deprecated_to_esp_extra('ip_pool')

View File

@@ -13,7 +13,12 @@ class MandrillBackendDjrillFeatureTests(MandrillBackendMockAPITestCase):
# These features should now be accessed through esp_extra
def test_async(self):
self.message.async = True
# async becomes a keyword in Python 3.7. If you have code like this:
# self.message.async = True
# it should be changed to:
# self.message.esp_extra = {"async": True}
# (The setattr below keeps these tests compatible, but isn't recommended for your code.)
setattr(self.message, 'async', True) # don't do this; use esp_extra instead
with self.assertWarnsRegex(DeprecationWarning, 'async'):
self.message.send()
data = self.get_api_call_json()