From 138f32471c5dfe12299471037782ac353462be74 Mon Sep 17 00:00:00 2001 From: Daniel Hones Date: Mon, 8 Feb 2021 23:58:54 -0500 Subject: Updated webutils.highlight_content to ignore double-quotes when highlighting query parts --- tests/unit/test_webutils.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests/unit') diff --git a/tests/unit/test_webutils.py b/tests/unit/test_webutils.py index aa464688b..023374b04 100644 --- a/tests/unit/test_webutils.py +++ b/tests/unit/test_webutils.py @@ -34,6 +34,28 @@ class TestWebUtils(SearxTestCase): query = 'a test' self.assertEqual(webutils.highlight_content(content, query), content) + data = ( + ('" test "', + 'a test string', + 'a test string'), + ('"a"', + 'this is a test string', + 'this is a test string'), + ('a test', + 'this is a test string that matches entire query', + 'this is a test string that matches entire query'), + ('this a test', + 'this is a string to test.', + ('this is a ' + 'string to test.')), + ('match this "exact phrase"', + 'this string contains the exact phrase we want to match', + ('this string contains the exact' + ' phrase we want to match')) + ) + for query, content, expected in data: + self.assertEqual(webutils.highlight_content(content, query), expected) + class TestUnicodeWriter(SearxTestCase): -- cgit v1.2.3