From ec0ee336a2ae0df0411dbabcc4b17d3492900e16 Mon Sep 17 00:00:00 2001 From: medmunds Date: Mon, 26 Feb 2018 10:24:08 -0800 Subject: [PATCH] Cleanup: Avoid Python 3.7 deprecation warning on 'async' keyword Fixes #92 --- anymail/backends/mandrill.py | 4 ++-- tests/test_mandrill_djrill_features.py | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/anymail/backends/mandrill.py b/anymail/backends/mandrill.py index efe3197..f6fa1b2 100644 --- a/anymail/backends/mandrill.py +++ b/anymail/backends/mandrill.py @@ -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') diff --git a/tests/test_mandrill_djrill_features.py b/tests/test_mandrill_djrill_features.py index 9a38e0b..4c114c2 100644 --- a/tests/test_mandrill_djrill_features.py +++ b/tests/test_mandrill_djrill_features.py @@ -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()