diff options
author | Alexandre Flament <alex@al-f.net> | 2023-01-17 23:24:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-17 23:24:04 +0100 |
commit | 6d72ef3cbec5246fd52498932760ea2f975a3112 (patch) | |
tree | 9414146f13f65fa476f09bf0337e3ccce175062f /tests | |
parent | 13b0c251c45c3d14700723b25b601be56178e8df (diff) | |
parent | 99b5272d9a17ffd813fc8c0b2f3cae3201d2398e (diff) | |
download | searxng-6d72ef3cbec5246fd52498932760ea2f975a3112.tar.gz searxng-6d72ef3cbec5246fd52498932760ea2f975a3112.zip |
Merge pull request #2109 from ahmad-alkadri/fix/highlight-full-word
Standalone words highlighting for query result in non-CJK characters
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>', + ] ), ), ) |