Support Python 3.6 with Django 1.11-alpha

Only real problem is in json serialization tests:
Python 3.6 [changed][1] the json serialization
error message to use the object's class name
rather than its repr. E.g.:
  "Decimal('19.99') is not JSON serializable"
becomes:
  "Object of type 'Decimal' is not JSON serializable"

Update tests that looked for specific serialization
error message to just look for the word "Decimal"
instead. (Works with all Python versions.)

[1]: https://bugs.python.org/issue26623
This commit is contained in:
medmunds
2017-01-22 11:21:58 -08:00
parent 33fdd0fb49
commit 23800657b8
5 changed files with 10 additions and 10 deletions

View File

@@ -163,7 +163,7 @@ class SendGridBackendStandardEmailTests(SendGridBackendMockAPITestCase):
def test_extra_headers_serialization_error(self):
self.message.extra_headers = {'X-Custom': Decimal(12.5)}
with self.assertRaisesMessage(AnymailSerializationError, "Decimal('12.5')"):
with self.assertRaisesMessage(AnymailSerializationError, "Decimal"):
self.message.send()
def test_reply_to(self):
@@ -592,7 +592,7 @@ class SendGridBackendAnymailFeatureTests(SendGridBackendMockAPITestCase):
err = cm.exception
self.assertIsInstance(err, TypeError) # compatibility with json.dumps
self.assertIn("Don't know how to send this data to SendGrid", str(err)) # our added context
self.assertIn("Decimal('19.99') is not JSON serializable", str(err)) # original message
self.assertRegex(str(err), r"Decimal.*is not JSON serializable") # original message
class SendGridBackendRecipientsRefusedTests(SendGridBackendMockAPITestCase):