Navigation Menu

Skip to content

Commit

Permalink
multiple index tests: correct handling of Whoosh teardown
Browse files Browse the repository at this point in the history
We can't remove the Whoosh directory per-test - only after every
test has run…
  • Loading branch information
acdha committed Dec 11, 2012
1 parent 21bf53b commit 048b376
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tests/multipleindex/tests.py
@@ -1,3 +1,4 @@
import os
import shutil
from django.conf import settings
from django.test import TestCase
Expand All @@ -8,6 +9,15 @@
from multipleindex.search_indexes import FooIndex
from multipleindex.models import Foo, Bar

def tearDownModule():
# Because Whoosh doesn't clean up its mess.
for name, opts in settings.HAYSTACK_CONNECTIONS.items():
if "WhooshEngine" not in opts['ENGINE']:
continue
p = opts['PATH']
if os.path.exists(p):
shutil.rmtree(p)


class MultipleIndexTestCase(TestCase):
def setUp(self):
Expand Down Expand Up @@ -46,8 +56,7 @@ def setUp(self):
def tearDown(self):
self.fi.clear()
self.bi.clear()
# Because Whoosh doesn't clean up its mess.
shutil.rmtree(settings.HAYSTACK_CONNECTIONS['whoosh']['PATH'])

super(MultipleIndexTestCase, self).setUp()

def test_index_update_object_using(self):
Expand Down

0 comments on commit 048b376

Please sign in to comment.