From 9bf34a936d420af85c81ed316421c217c2e0e4ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20C=2E=20Leit=C3=A3o?= Date: Sun, 11 May 2014 16:24:23 +0200 Subject: [PATCH] Simplifed tests code by removing duplicate code. --- tests/xapian_tests/tests/xapian_backend.py | 24 ++++------------------ 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/tests/xapian_tests/tests/xapian_backend.py b/tests/xapian_tests/tests/xapian_backend.py index 6341eaa..04da2fa 100644 --- a/tests/xapian_tests/tests/xapian_backend.py +++ b/tests/xapian_tests/tests/xapian_backend.py @@ -123,6 +123,9 @@ class HaystackBackendTestCase(object): def get_index(self): raise NotImplementedError + def get_objects(self): + raise NotImplementedError + def setUp(self): self.old_ui = connections['default'].get_unified_index() self.ui = UnifiedIndex() @@ -132,6 +135,7 @@ class HaystackBackendTestCase(object): connections['default']._index = self.ui def tearDown(self): + self.backend.clear() connections['default']._index = self.old_ui @@ -150,10 +154,6 @@ class XapianBackendTestCase(HaystackBackendTestCase, TestCase): self.backend.update(self.index, [mock]) - def tearDown(self): - self.backend.clear() - super(XapianBackendTestCase, self).tearDown() - def test_fields(self): """ Tests that all fields are in the database @@ -223,10 +223,6 @@ class XapianSearchBackendTestCase(HaystackBackendTestCase, TestCase): self.backend.update(self.index, self.sample_objs) - def tearDown(self): - self.backend.clear() - super(XapianSearchBackendTestCase, self).tearDown() - def test_update(self): self.assertEqual(self.backend.document_count(), 3) self.assertEqual([result.pk for result in self.backend.search(xapian.Query(''))['results']], [1, 2, 3]) @@ -479,10 +475,6 @@ class LiveXapianSearchQueryTestCase(HaystackBackendTestCase, TestCase): self.sq = connections['default'].get_query() - def tearDown(self): - self.backend.clear() - super(LiveXapianSearchQueryTestCase, self).tearDown() - def test_get_spelling(self): self.sq.add_filter(SQ(content='indxd')) self.assertEqual(self.sq.get_spelling_suggestion(), u'indexed') @@ -567,10 +559,6 @@ class LiveXapianSearchQuerySetTestCase(HaystackBackendTestCase, TestCase): self.sq = connections['default'].get_query() self.sqs = SearchQuerySet() - def tearDown(self): - self.backend.clear() - super(LiveXapianSearchQuerySetTestCase, self).tearDown() - def test_result_class(self): # Assert that we're defaulting to ``SearchResult``. sqs = self.sqs.all() @@ -621,10 +609,6 @@ class XapianBoostBackendTestCase(HaystackBackendTestCase, TestCase): self.backend.update(self.index, self.sample_objs) - def tearDown(self): - self.backend.clear() - super(XapianBoostBackendTestCase, self).tearDown() - def test_boost(self): sqs = SearchQuerySet()