diff options
author | ahmad-alkadri <ahmad.alkadri@outlook.com> | 2023-01-15 15:08:11 +0000 |
---|---|---|
committer | Ahmad Alkadri <ahmad.alkadri@outlook.com> | 2023-01-15 16:51:31 +0100 |
commit | 99b5272d9a17ffd813fc8c0b2f3cae3201d2398e (patch) | |
tree | 1742000ca4b3ac8118bb227139dacb704f9e7800 /tests | |
parent | 6c421110b57c695e9c0a0d9212bc271d701d17da (diff) | |
download | searxng-99b5272d9a17ffd813fc8c0b2f3cae3201d2398e.tar.gz searxng-99b5272d9a17ffd813fc8c0b2f3cae3201d2398e.zip |
A little fix and modified the testing for content highlight
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/test_webutils.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/tests/unit/test_webutils.py b/tests/unit/test_webutils.py index 31a0f86ce..acf1aeeb7 100644 --- a/tests/unit/test_webutils.py +++ b/tests/unit/test_webutils.py @@ -28,32 +28,33 @@ class TestWebUtils(SearxTestCase): content = 'a' query = 'test' - self.assertEqual(webutils.highlight_content(content, query), content) + self.assertEqual(webutils.highlight_content(content, query), 'a') query = 'a test' - self.assertEqual(webutils.highlight_content(content, query), content) + self.assertEqual(webutils.highlight_content(content, query), '<span class="highlight">a</span>') data = ( ('" test "', 'a test string', 'a <span class="highlight">test</span> string'), - ('"a"', 'this is a test string', 'this is<span class="highlight"> a </span>test string'), + ('"a"', 'this is a test string', 'this is <span class="highlight">a</span> test string'), ( 'a test', 'this is a test string that matches entire query', - 'this is <span class="highlight">a test</span> string that matches entire query', + 'this is <span class="highlight">a</span> <span class="highlight">test</span> string that matches entire query', ), ( 'this a test', 'this is a string to test.', ( - '<span class="highlight">this</span> is<span class="highlight"> a </span>' - 'string to <span class="highlight">test</span>.' + '<span class="highlight">this</span> is <span class="highlight">a</span> string to <span class="highlight">test</span>.' ), ), ( 'match this "exact phrase"', 'this string contains the exact phrase we want to match', - ( - '<span class="highlight">this</span> string contains the <span class="highlight">exact</span>' - ' <span class="highlight">phrase</span> we want to <span class="highlight">match</span>' + ''.join( + [ + '<span class="highlight">this</span> string contains the <span class="highlight">exact</span> ', + '<span class="highlight">phrase</span> we want to <span class="highlight">match</span>', + ] ), ), ) |