mirror of
https://github.com/Hopiu/xapian-haystack.git
synced 2026-05-04 21:44:48 +00:00
Cleaned up setUp an tearDown
This commit is contained in:
parent
b94eee10c5
commit
8987c532c6
1 changed files with 2 additions and 13 deletions
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
import datetime
|
||||
import os
|
||||
import shutil
|
||||
|
||||
from django.conf import settings
|
||||
from django.test import TestCase
|
||||
|
|
@ -29,24 +30,12 @@ from core.models import MockModel, AnotherMockModel
|
|||
class XapianSearchQueryTestCase(TestCase):
|
||||
def setUp(self):
|
||||
super(XapianSearchQueryTestCase, self).setUp()
|
||||
|
||||
# Stow.
|
||||
temp_path = os.path.join('tmp', 'test_xapian_query')
|
||||
self.old_xapian_path = getattr(settings, 'HAYSTACK_XAPIAN_PATH', temp_path)
|
||||
settings.HAYSTACK_XAPIAN_PATH = temp_path
|
||||
|
||||
self.sq = SearchQuery(backend=SearchBackend())
|
||||
|
||||
def tearDown(self):
|
||||
if os.path.exists(settings.HAYSTACK_XAPIAN_PATH):
|
||||
index_files = os.listdir(settings.HAYSTACK_XAPIAN_PATH)
|
||||
shutil.rmtree(settings.HAYSTACK_XAPIAN_PATH)
|
||||
|
||||
for index_file in index_files:
|
||||
os.remove(os.path.join(settings.HAYSTACK_XAPIAN_PATH, index_file))
|
||||
|
||||
os.removedirs(settings.HAYSTACK_XAPIAN_PATH)
|
||||
|
||||
settings.HAYSTACK_XAPIAN_PATH = self.old_xapian_path
|
||||
super(XapianSearchQueryTestCase, self).tearDown()
|
||||
|
||||
def test_build_query_all(self):
|
||||
|
|
|
|||
Loading…
Reference in a new issue