From d3ac4a1542fe4e53ccb824e930387099d2dec3b6 Mon Sep 17 00:00:00 2001 From: medmunds Date: Tue, 15 May 2018 11:36:00 -0700 Subject: [PATCH] Drop Python 3.3-specific tests --- tests/test_amazon_ses_backend.py | 8 +------- tests/test_inbound.py | 6 +----- tests/utils.py | 17 ----------------- 3 files changed, 2 insertions(+), 29 deletions(-) diff --git a/tests/test_amazon_ses_backend.py b/tests/test_amazon_ses_backend.py index 1de828c..a8a85f7 100644 --- a/tests/test_amazon_ses_backend.py +++ b/tests/test_amazon_ses_backend.py @@ -4,7 +4,6 @@ from __future__ import unicode_literals import json from datetime import datetime from email.mime.application import MIMEApplication -from unittest import skipIf import botocore.config import botocore.exceptions @@ -18,9 +17,7 @@ from mock import ANY, patch from anymail.exceptions import AnymailAPIError, AnymailUnsupportedFeature from anymail.inbound import AnymailInboundMessage from anymail.message import attach_inline_image_file, AnymailMessage -from .utils import ( - AnymailTestMixin, SAMPLE_IMAGE_FILENAME, python_has_broken_mime_param_handling, - sample_image_content, sample_image_path) +from .utils import AnymailTestMixin, SAMPLE_IMAGE_FILENAME, sample_image_content, sample_image_path @override_settings(EMAIL_BACKEND='anymail.backends.amazon_ses.EmailBackend') @@ -152,9 +149,6 @@ class AmazonSESBackendStandardEmailTests(AmazonSESBackendMockAPITestCase): self.assertIn(b"\nCc: cc@xn--th-e0a.example.com\n", raw_mime) # SES doesn't support non-ASCII in the username@ part (RFC 6531 "SMTPUTF8" extension) - @skipIf(python_has_broken_mime_param_handling(), - "This Python has a buggy email package that crashes on non-ASCII " - "characters in RFC2231-encoded MIME header parameters") def test_attachments(self): text_content = "• Item one\n• Item two\n• Item three" # those are \u2022 bullets ("\N{BULLET}") self.message.attach(filename="Une pièce jointe.txt", # utf-8 chars in filename diff --git a/tests/test_inbound.py b/tests/test_inbound.py index 5a4e0d8..7aee2db 100644 --- a/tests/test_inbound.py +++ b/tests/test_inbound.py @@ -5,14 +5,13 @@ import quopri from base64 import b64encode from email.utils import collapse_rfc2231_value from textwrap import dedent -from unittest import skipIf from django.core.mail import SafeMIMEText from django.test import SimpleTestCase from anymail.inbound import AnymailInboundMessage -from .utils import SAMPLE_IMAGE_FILENAME, python_has_broken_mime_param_handling, sample_email_path, sample_image_content +from .utils import SAMPLE_IMAGE_FILENAME, sample_email_path, sample_image_content SAMPLE_IMAGE_CONTENT = sample_image_content() @@ -566,9 +565,6 @@ class EmailParserWorkaroundTests(SimpleTestCase): # Replace illegal encodings (rather than causing error): self.assertEqual(msg["X-Broken"], "Not a char: \N{REPLACEMENT CHARACTER}.") - @skipIf(python_has_broken_mime_param_handling(), - "This Python has a buggy email package that crashes on non-ASCII " - "characters in RFC2231-encoded MIME header parameters") def test_parse_encoded_params(self): raw = dedent("""\ MIME-Version: 1.0 diff --git a/tests/utils.py b/tests/utils.py index 1fd7e00..b16f691 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -300,20 +300,3 @@ class ClientWithCsrfChecks(Client): def __init__(self, **defaults): super(ClientWithCsrfChecks, self).__init__( enforce_csrf_checks=True, **defaults) - - -def python_has_broken_mime_param_handling(): - # In Python 3.3 (only), trying to access any parsed MIME header will crash if the header - # has parameters with non-ASCII characters. (Common in, e.g., attachment filenames.) - # The bug is somewhere within email._header_value_parser.parse_mime_parameters, and is too - # complicated to work around for an uncommon version combination (Django 1.8 on Python 3.3). - # If you run into it, please upgrade to (at least) Python 3.4. - try: - from email.policy import default - default.header_fetch_parse("Content-Type", "plain; name*=iso-8859-1''Une%20pi%E8ce") - except ImportError: - return False # Python 2 (or pre Python 3.3) -- bug doesn't apply - except UnicodeEncodeError: - return True # this is the bug - else: - return False # worked fine