From aed68f68943bce8fcc0c3382ea74ceceff072952 Mon Sep 17 00:00:00 2001 From: Karl Hobley Date: Sun, 18 Jan 2015 15:00:29 +0000 Subject: [PATCH] Removed duplicate filters test This often causes travis to fail for no reason. The thing it's testing is unlikely to break in the future so it's causing more trouble that it's worth. --- wagtail/tests/utils.py | 32 ---------------------- wagtail/wagtailimages/tests/test_models.py | 26 +----------------- 2 files changed, 1 insertion(+), 57 deletions(-) diff --git a/wagtail/tests/utils.py b/wagtail/tests/utils.py index e5a9cbbdf4..fd155e6b45 100644 --- a/wagtail/tests/utils.py +++ b/wagtail/tests/utils.py @@ -1,6 +1,5 @@ from contextlib import contextmanager import warnings -import threading from django.contrib.auth import get_user_model from django.utils import six @@ -29,34 +28,3 @@ class WagtailTestUtils(object): for w in warning_list: if not issubclass(w.category, DeprecationWarning): warnings.showwarning(message=w.message, category=w.category, filename=w.filename, lineno=w.lineno, file=w.file, line=w.line) - - -# from http://www.caktusgroup.com/blog/2009/05/26/testing-django-views-for-concurrency-issues/ -def test_concurrently(times): - """ - Add this decorator to small pieces of code that you want to test - concurrently to make sure they don't raise exceptions when run at the - same time. E.g., some Django views that do a SELECT and then a subsequent - INSERT might fail when the INSERT assumes that the data has not changed - since the SELECT. - """ - def test_concurrently_decorator(test_func): - def wrapper(*args, **kwargs): - exceptions = [] - def call_test_func(): - try: - test_func(*args, **kwargs) - except Exception as e: - exceptions.append(e) - raise - threads = [] - for i in range(times): - threads.append(threading.Thread(target=call_test_func)) - for t in threads: - t.start() - for t in threads: - t.join() - if exceptions: - raise Exception('test_concurrently intercepted %s exceptions: %s' % (len(exceptions), exceptions)) - return wrapper - return test_concurrently_decorator diff --git a/wagtail/wagtailimages/tests/test_models.py b/wagtail/wagtailimages/tests/test_models.py index 52f7d352c3..fa34344178 100644 --- a/wagtail/wagtailimages/tests/test_models.py +++ b/wagtail/wagtailimages/tests/test_models.py @@ -11,7 +11,7 @@ from django.core.files.uploadedfile import SimpleUploadedFile from django.db.utils import IntegrityError from django.db import connection -from wagtail.tests.utils import WagtailTestUtils, test_concurrently +from wagtail.tests.utils import WagtailTestUtils from wagtail.wagtailcore.models import Page from wagtail.tests.models import EventPage, EventPageCarouselItem from wagtail.wagtailimages.models import Rendition, Filter, SourceImageIOError @@ -372,27 +372,3 @@ class TestIssue312(TestCase): height=rend1.height, focal_point_key=rend1.focal_point_key, ) - - def test_duplicate_filters(self): - @test_concurrently(10) - def get_renditions(): - # Create an image - image = Image.objects.create( - title="Concurrency test image", - file=get_test_image_file(), - ) - # get renditions concurrently, using various filters that are unlikely to exist already - for width in range(10, 100, 10): - image.get_rendition('width-%d' % width) - - image.delete() - - # this block opens multiple database connections, which need to be closed explicitly - # so that we can drop the test database at the end of the test run - connection.close() - - get_renditions() - # if the above has completed with no race conditions, there should be precisely one - # of each of the above filters in the database - for width in range(10, 100, 10): - self.assertEqual(Filter.objects.filter(spec='width-%d' % width).count(), 1)