From da260de1a0502f39311c60032ad32a2af00f6c6e Mon Sep 17 00:00:00 2001 From: medmunds Date: Thu, 14 May 2015 11:39:57 -0700 Subject: [PATCH] Drop support for Django 1.3, Python 2.6 and 3.2. * Shrink the Travis test matrix * Remove a lot of backported test code * Update requirements in setup.py * Update docs Closes #79 --- .travis.yml | 15 +--- README.rst | 2 +- djrill/tests/mock_backend.py | 5 +- djrill/tests/test_mandrill_integration.py | 12 +-- djrill/tests/test_mandrill_send.py | 12 +-- djrill/tests/test_mandrill_subaccounts.py | 4 +- djrill/tests/test_mandrill_webhook.py | 6 +- djrill/tests/utils.py | 89 ----------------------- docs/history.rst | 7 ++ setup.py | 4 +- 10 files changed, 25 insertions(+), 131 deletions(-) diff --git a/.travis.yml b/.travis.yml index 338886c..21f3e78 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,19 +1,10 @@ language: python matrix: include: - # Django 1.3: Python 2.6--2.7 - - python: "2.6" - env: DJANGO=django==1.3 - - python: "2.7" - env: DJANGO=django==1.3 - # Django 1.4: Python 2.6--2.7 - - python: "2.6" - env: DJANGO=django==1.4 + # Django 1.4: Python 2.6--2.7 (but we don't support 2.6) - python: "2.7" env: DJANGO=django==1.4 # Django 1.5: Python 2.7, pypy - # (As of Django 1.5, Python 2.6 no longer "highly recommended", - # and Python 3.2+ support was only "experimental", so skip those.) - python: "2.7" env: DJANGO=django==1.5 - python: "pypy" @@ -21,8 +12,6 @@ matrix: # Django 1.6: Python 2.7--3.3, pypy - python: "2.7" env: DJANGO=django==1.6 - - python: "3.2" - env: DJANGO=django==1.6 - python: "3.3" env: DJANGO=django==1.6 - python: "pypy" @@ -30,8 +19,6 @@ matrix: # Django 1.7: Python 2.7--3.4, pypy - python: "2.7" env: DJANGO=django==1.7 - - python: "3.2" - env: DJANGO=django==1.7 - python: "3.3" env: DJANGO=django==1.7 - python: "3.4" diff --git a/README.rst b/README.rst index 6e0dab3..a1ab707 100644 --- a/README.rst +++ b/README.rst @@ -29,7 +29,7 @@ package. It includes: * Optional support for Mandrill inbound email and other webhook notifications, via Django signals -Djrill is released under the BSD license. It is tested against Django 1.3--1.8 +Djrill is released under the BSD license. It is tested against Django 1.4--1.8 (including Python 3 with Django 1.6+, and PyPy support with Django 1.5+). Djrill uses `semantic versioning `_. diff --git a/djrill/tests/mock_backend.py b/djrill/tests/mock_backend.py index e119db2..a675cd9 100644 --- a/djrill/tests/mock_backend.py +++ b/djrill/tests/mock_backend.py @@ -4,13 +4,12 @@ import requests import six from django.test import TestCase - -from .utils import BackportedAssertions, override_settings +from django.test.utils import override_settings @override_settings(MANDRILL_API_KEY="FAKE_API_KEY_FOR_TESTING", EMAIL_BACKEND="djrill.mail.backends.djrill.DjrillBackend") -class DjrillBackendMockAPITestCase(TestCase, BackportedAssertions): +class DjrillBackendMockAPITestCase(TestCase): """TestCase that uses Djrill EmailBackend with a mocked Mandrill API""" class MockResponse(requests.Response): diff --git a/djrill/tests/test_mandrill_integration.py b/djrill/tests/test_mandrill_integration.py index a949326..99b0235 100644 --- a/djrill/tests/test_mandrill_integration.py +++ b/djrill/tests/test_mandrill_integration.py @@ -1,26 +1,22 @@ from __future__ import unicode_literals import os +import unittest from django.core import mail from django.test import TestCase +from django.test.utils import override_settings from djrill import MandrillAPIError -from djrill.tests.utils import BackportedAssertions, override_settings - -try: - from unittest import skipUnless -except ImportError: - from django.utils.unittest import skipUnless MANDRILL_TEST_API_KEY = os.getenv('MANDRILL_TEST_API_KEY') -@skipUnless(MANDRILL_TEST_API_KEY, +@unittest.skipUnless(MANDRILL_TEST_API_KEY, "Set MANDRILL_TEST_API_KEY environment variable to run integration tests") @override_settings(MANDRILL_API_KEY=MANDRILL_TEST_API_KEY, EMAIL_BACKEND="djrill.mail.backends.djrill.DjrillBackend") -class DjrillIntegrationTests(TestCase, BackportedAssertions): +class DjrillIntegrationTests(TestCase): """Mandrill API integration tests These tests run against the **live** Mandrill API, using the diff --git a/djrill/tests/test_mandrill_send.py b/djrill/tests/test_mandrill_send.py index 8bbbc9a..43e9cf4 100644 --- a/djrill/tests/test_mandrill_send.py +++ b/djrill/tests/test_mandrill_send.py @@ -10,20 +10,16 @@ from email.mime.image import MIMEImage import json import os import six - -try: - from unittest import SkipTest -except ImportError: - from django.utils.unittest import SkipTest +import unittest from django.core import mail from django.core.exceptions import ImproperlyConfigured from django.core.mail import make_msgid from django.test import TestCase +from django.test.utils import override_settings from djrill import MandrillAPIError, NotSupportedByMandrillError -from .mock_backend import DjrillBackendMockAPITestCase -from .utils import override_settings +from djrill.tests.mock_backend import DjrillBackendMockAPITestCase def decode_att(att): @@ -158,7 +154,7 @@ class DjrillBackendTests(DjrillBackendMockAPITestCase): headers={'X-Other': 'Keep'}) except TypeError: # Pre-Django 1.8 - raise SkipTest("Django version doesn't support EmailMessage(reply_to)") + raise unittest.SkipTest("Django version doesn't support EmailMessage(reply_to)") email.send() self.assert_mandrill_called("/messages/send.json") data = self.get_api_call_data() diff --git a/djrill/tests/test_mandrill_subaccounts.py b/djrill/tests/test_mandrill_subaccounts.py index 3d9a1e8..920221f 100644 --- a/djrill/tests/test_mandrill_subaccounts.py +++ b/djrill/tests/test_mandrill_subaccounts.py @@ -1,7 +1,7 @@ from django.core import mail +from django.test.utils import override_settings -from .mock_backend import DjrillBackendMockAPITestCase -from .utils import override_settings +from djrill.tests.mock_backend import DjrillBackendMockAPITestCase class DjrillMandrillSubaccountTests(DjrillBackendMockAPITestCase): diff --git a/djrill/tests/test_mandrill_webhook.py b/djrill/tests/test_mandrill_webhook.py index 52c3f64..9089a4c 100644 --- a/djrill/tests/test_mandrill_webhook.py +++ b/djrill/tests/test_mandrill_webhook.py @@ -6,10 +6,10 @@ import json from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.test import TestCase +from django.test.utils import override_settings -from ..compat import b -from ..signals import webhook_event -from .utils import override_settings +from djrill.compat import b +from djrill.signals import webhook_event class DjrillWebhookSecretMixinTests(TestCase): diff --git a/djrill/tests/utils.py b/djrill/tests/utils.py index fc372e9..add2a83 100644 --- a/djrill/tests/utils.py +++ b/djrill/tests/utils.py @@ -1,94 +1,5 @@ -import re -import six import sys -__all__ = ( - 'BackportedAssertions', - 'override_settings', - 'reset_warning_registry', -) - -try: - from django.test.utils import override_settings - -except ImportError: - # Back-port override_settings from Django 1.4 - # https://github.com/django/django/blob/stable/1.4.x/django/test/utils.py - from django.conf import settings, UserSettingsHolder - from django.utils.functional import wraps - - class override_settings(object): - """ - Acts as either a decorator, or a context manager. If it's a decorator it - takes a function and returns a wrapped function. If it's a contextmanager - it's used with the ``with`` statement. In either event entering/exiting - are called before and after, respectively, the function/block is executed. - """ - def __init__(self, **kwargs): - self.options = kwargs - self.wrapped = settings._wrapped - - def __enter__(self): - self.enable() - - def __exit__(self, exc_type, exc_value, traceback): - self.disable() - - def __call__(self, test_func): - from django.test import TransactionTestCase - if isinstance(test_func, type) and issubclass(test_func, TransactionTestCase): - original_pre_setup = test_func._pre_setup - original_post_teardown = test_func._post_teardown - def _pre_setup(innerself): - self.enable() - original_pre_setup(innerself) - def _post_teardown(innerself): - original_post_teardown(innerself) - self.disable() - test_func._pre_setup = _pre_setup - test_func._post_teardown = _post_teardown - return test_func - else: - @wraps(test_func) - def inner(*args, **kwargs): - with self: - return test_func(*args, **kwargs) - return inner - - def enable(self): - override = UserSettingsHolder(settings._wrapped) - for key, new_value in self.options.items(): - setattr(override, key, new_value) - settings._wrapped = override - # No setting_changed signal in Django 1.3 - # for key, new_value in self.options.items(): - # setting_changed.send(sender=settings._wrapped.__class__, - # setting=key, value=new_value) - - def disable(self): - settings._wrapped = self.wrapped - # No setting_changed signal in Django 1.3 - # for key in self.options: - # new_value = getattr(settings, key, None) - # setting_changed.send(sender=settings._wrapped.__class__, - # setting=key, value=new_value) - - -class BackportedAssertions(object): - """Handful of useful TestCase assertions backported to Python 2.6/Django 1.3""" - - # Backport from Python 2.7/3.1 - def assertIn(self, member, container, msg=None): - """Just like self.assertTrue(a in b), but with a nicer default message.""" - if member not in container: - self.fail(msg or '%r not found in %r' % (member, container)) - - # Backport from Django 1.4 - def assertRaisesMessage(self, expected_exception, expected_message, - callable_obj=None, *args, **kwargs): - return six.assertRaisesRegex(self, expected_exception, re.escape(expected_message), - callable_obj, *args, **kwargs) - # Backport from Django 1.8 (django.test.utils) # with fix suggested by https://code.djangoproject.com/ticket/21049 diff --git a/docs/history.rst b/docs/history.rst index 745b2f7..3e87ac5 100644 --- a/docs/history.rst +++ b/docs/history.rst @@ -21,6 +21,13 @@ in debug mode.) Breaking Changes in Djrill 2.0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Dropped support for Django 1.3, Python 2.6, and Python 3.2 + Although Djrill may still work with these older configurations, + we no longer test against them. Djrill now requires Django 1.4 + or later and Python 2.7, 3.3, or 3.4. + + If you require earlier support, Djrill 1.4 remains available. + Removed DjrillAdminSite Earlier versions of Djrill included a custom Django admin site. The equivalent functionality is available in Mandrill's dashboard. diff --git a/setup.py b/setup.py index 2c5ef2e..43ae67e 100644 --- a/setup.py +++ b/setup.py @@ -29,7 +29,7 @@ setup( license="BSD License", packages=["djrill"], zip_safe=False, - install_requires=["requests>=1.0.0", "django>=1.3"], + install_requires=["requests>=1.0.0", "django>=1.4"], include_package_data=True, test_suite="runtests.runtests", tests_require=["mock", "six"], @@ -37,10 +37,8 @@ setup( "Programming Language :: Python", "Programming Language :: Python :: Implementation :: PyPy", "Programming Language :: Python :: Implementation :: CPython", - "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "License :: OSI Approved :: BSD License",