@@ -2,7 +2,6 @@
22
33import json
44from urlparse import ParseResult
5−from mock import patch
65from searx import webapp
76from searx.testing import SearxTestCase
87
@@ -33,6 +32,11 @@ class ViewsTestCase(SearxTestCase):
3332 },
3433 ]
3534
35+ def search_mock(search_self, *args):
36+ search_self.results = self.test_results
37+
38+ webapp.Search.search = search_mock
39+
3640 self.maxDiff = None # to see full diffs
3741
3842 def test_index_empty(self):
@@ -40,14 +44,7 @@ class ViewsTestCase(SearxTestCase):
4044 self.assertEqual(result.status_code, 200)
4145 self.assertIn('<div class="title"><h1>searx</h1></div>', result.data)
4246
43− @patch('searx.search.Search.search')
44− def test_index_html(self, search):
45− search.return_value = (
46− self.test_results,
47− set(),
48− set(),
49− set()
50− )
47+ def test_index_html(self):
5148 result = self.app.post('/', data={'q': 'test'})
5249 self.assertIn(
5350 '<h3 class="result_title"><img width="14" height="14" class="favicon" src="/static/themes/default/img/icons/icon_youtube.ico" alt="youtube" /><a href="http://second.test.xyz">Second <span class="highlight">Test</span></a></h3>', # noqa
@@ -58,14 +55,7 @@ class ViewsTestCase(SearxTestCase):
5855 result.data
5956 )
6057
61− @patch('searx.search.Search.search')
62− def test_index_json(self, search):
63− search.return_value = (
64− self.test_results,
65− set(),
66− set(),
67− set()
68− )
58+ def test_index_json(self):
6959 result = self.app.post('/', data={'q': 'test', 'format': 'json'})
7060
7161 result_dict = json.loads(result.data)
@@ -76,14 +66,7 @@ class ViewsTestCase(SearxTestCase):
7666 self.assertEqual(
7767 result_dict['results'][0]['url'], 'http://first.test.xyz')
7868
79− @patch('searx.search.Search.search')
80− def test_index_csv(self, search):
81− search.return_value = (
82− self.test_results,
83− set(),
84− set(),
85− set()
86− )
69+ def test_index_csv(self):
8770 result = self.app.post('/', data={'q': 'test', 'format': 'csv'})
8871
8972 self.assertEqual(
@@ -93,14 +76,7 @@ class ViewsTestCase(SearxTestCase):
9376 result.data
9477 )
9578
96− @patch('searx.search.Search.search')
97− def test_index_rss(self, search):
98− search.return_value = (
99− self.test_results,
100− set(),
101− set(),
102− set()
103− )
79+ def test_index_rss(self):
10480 result = self.app.post('/', data={'q': 'test', 'format': 'rss'})
10581
10682 self.assertIn(