From 3a92774f8c5a91874a57f765c81fa61c25af04a7 Mon Sep 17 00:00:00 2001 From: Matt Westcott Date: Fri, 16 Dec 2016 15:00:55 +0000 Subject: [PATCH] Remove deprecation path for ImageOperation.run methods that don't accept env --- wagtail/wagtailimages/models.py | 22 ++------------ .../tests/test_image_operations.py | 30 ------------------- 2 files changed, 2 insertions(+), 50 deletions(-) diff --git a/wagtail/wagtailimages/models.py b/wagtail/wagtailimages/models.py index dbf4d53099..13136f0d26 100644 --- a/wagtail/wagtailimages/models.py +++ b/wagtail/wagtailimages/models.py @@ -1,7 +1,6 @@ from __future__ import absolute_import, unicode_literals import hashlib -import inspect import os.path import warnings from collections import OrderedDict @@ -25,7 +24,7 @@ from taggit.managers import TaggableManager from unidecode import unidecode from willow.image import Image as WillowImage -from wagtail.utils.deprecation import RemovedInWagtail19Warning, RemovedInWagtail110Warning +from wagtail.utils.deprecation import RemovedInWagtail110Warning from wagtail.wagtailadmin.utils import get_object_usage from wagtail.wagtailcore import hooks from wagtail.wagtailcore.models import CollectionMember @@ -404,24 +403,7 @@ class Filter(models.Model): 'original-format': original_format, } for operation in self.operations: - # Check that the operation can take the "env" argument - try: - inspect.getcallargs(operation.run, willow, image, env) - accepts_env = True - except TypeError: - # Check that the paramters fit the old style, so we don't - # raise a warning if there is a coding error - inspect.getcallargs(operation.run, willow, image) - accepts_env = False - warnings.warn("ImageOperation run methods should take 4 " - "arguments. %d.run only takes 3.", - RemovedInWagtail19Warning) - - # Call operation - if accepts_env: - willow = operation.run(willow, image, env) or willow - else: - willow = operation.run(willow, image) or willow + willow = operation.run(willow, image, env) or willow # Find the output format to use if 'output-format' in env: diff --git a/wagtail/wagtailimages/tests/test_image_operations.py b/wagtail/wagtailimages/tests/test_image_operations.py index ad467d6d81..aeef780c2b 100644 --- a/wagtail/wagtailimages/tests/test_image_operations.py +++ b/wagtail/wagtailimages/tests/test_image_operations.py @@ -1,12 +1,9 @@ from __future__ import absolute_import, unicode_literals -import warnings - from django.test import TestCase, override_settings from django.utils.six import BytesIO from mock import Mock, patch -from wagtail.utils.deprecation import RemovedInWagtail19Warning from wagtail.wagtailcore import hooks from wagtail.wagtailimages import image_operations from wagtail.wagtailimages.exceptions import InvalidFilterSpecError @@ -417,33 +414,6 @@ class TestFilter(TestCase): self.assertEqual(run_mock.call_count, 2) - def test_runs_operations_without_env_argument(self): - # The "env" argument was added in Wagtail 1.5. This tests that - # image operations written for 1.4 will still work - - run_mock = Mock() - - def run(willow, image): - run_mock(willow, image) - - self.operation_instance.run = run - - fil = Filter(spec='operation1|operation2') - image = Image.objects.create( - title="Test image", - file=get_test_image_file(), - ) - - with warnings.catch_warnings(record=True) as ws: - warnings.simplefilter('always') - - fil.run(image, BytesIO()) - - self.assertEqual(len(ws), 2) - self.assertIs(ws[0].category, RemovedInWagtail19Warning) - - self.assertEqual(run_mock.call_count, 2) - @hooks.register('register_image_operations') def register_image_operations():