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.
pull/915/head
Karl Hobley 2015-01-18 15:00:29 +00:00
rodzic 5658eabe02
commit aed68f6894
2 zmienionych plików z 1 dodań i 57 usunięć

Wyświetl plik

@ -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

Wyświetl plik

@ -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)