diff options
| author | Alexandre Flament <alex@al-f.net> | 2021-12-27 19:11:01 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-27 19:11:01 +0100 |
| commit | c6922ae7c5e53f695d5f5f8704b10b4e2815cda4 (patch) | |
| tree | 9c0456ad1a1d9d375311ccd8c9bd3eafd0779114 /tests/unit/test_standalone_searx.py | |
| parent | 54bce130f9074c3d63009237b014c727a1443cc5 (diff) | |
| parent | d84226bf63757b1d4245ab26e9c081daf42389aa (diff) | |
Merge pull request #619 from dalf/apply-black
Apply black
Diffstat (limited to 'tests/unit/test_standalone_searx.py')
| -rw-r--r-- | tests/unit/test_standalone_searx.py | 56 |
1 files changed, 29 insertions, 27 deletions
diff --git a/tests/unit/test_standalone_searx.py b/tests/unit/test_standalone_searx.py index c81598160..a3d8b4d4f 100644 --- a/tests/unit/test_standalone_searx.py +++ b/tests/unit/test_standalone_searx.py @@ -23,8 +23,7 @@ class StandaloneSearx(SearxTestCase): def test_parse_argument_no_args(self): """Test parse argument without args.""" - with patch.object(sys, 'argv', ['standalone_searx']), \ - self.assertRaises(SystemExit): + with patch.object(sys, 'argv', ['standalone_searx']), self.assertRaises(SystemExit): sys.stderr = io.StringIO() sas.parse_argument() sys.stdout = sys.__stderr__ @@ -33,8 +32,13 @@ class StandaloneSearx(SearxTestCase): """Test parse argument with basic args.""" query = 'red box' exp_dict = { - 'query': query, 'category': 'general', 'lang': 'all', 'pageno': 1, - 'safesearch': '0', 'timerange': None} + 'query': query, + 'category': 'general', + 'lang': 'all', + 'pageno': 1, + 'safesearch': '0', + 'timerange': None, + } args = ['standalone_searx', query] with patch.object(sys, 'argv', args): res = sas.parse_argument() @@ -45,16 +49,16 @@ class StandaloneSearx(SearxTestCase): def test_to_dict(self): """test to_dict.""" self.assertEqual( - sas.to_dict( - sas.get_search_query(sas.parse_argument(['red box']))), + sas.to_dict(sas.get_search_query(sas.parse_argument(['red box']))), { - 'search': { - 'q': 'red box', 'pageno': 1, 'lang': 'all', - 'safesearch': 0, 'timerange': None - }, - 'results': [], 'infoboxes': [], 'suggestions': [], - 'answers': [], 'paging': False, 'results_number': 0 - } + 'search': {'q': 'red box', 'pageno': 1, 'lang': 'all', 'safesearch': 0, 'timerange': None}, + 'results': [], + 'infoboxes': [], + 'suggestions': [], + 'answers': [], + 'paging': False, + 'results_number': 0, + }, ) def test_to_dict_with_mock(self): @@ -77,30 +81,28 @@ class StandaloneSearx(SearxTestCase): 'safesearch': m_sq.safesearch, 'timerange': m_sq.time_range, }, - 'suggestions': [] - } + 'suggestions': [], + }, ) def test_get_search_query(self): """test get_search_query.""" - args = sas.parse_argument(['rain', ]) + args = sas.parse_argument( + [ + 'rain', + ] + ) search_q = sas.get_search_query(args) self.assertTrue(search_q) - self.assertEqual(search_q, SearchQuery('rain', [EngineRef('engine1', 'general')], - 'all', 0, 1, None, None, None)) + self.assertEqual( + search_q, SearchQuery('rain', [EngineRef('engine1', 'general')], 'all', 0, 1, None, None, None) + ) def test_no_parsed_url(self): """test no_parsed_url func""" - self.assertEqual( - sas.no_parsed_url([{'parsed_url': 'http://example.com'}]), - [{}] - ) + self.assertEqual(sas.no_parsed_url([{'parsed_url': 'http://example.com'}]), [{}]) - @params( - (datetime.datetime(2020, 1, 1), '2020-01-01T00:00:00'), - ('a'.encode('utf8'), 'a'), - (set([1]), [1]) - ) + @params((datetime.datetime(2020, 1, 1), '2020-01-01T00:00:00'), ('a'.encode('utf8'), 'a'), (set([1]), [1])) def test_json_serial(self, arg, exp_res): """test json_serial func""" self.assertEqual(sas.json_serial(arg), exp_res) |