Fix - Regular Expression text in ignore and trigger were not processing correctly, also refactored for lower CPU usage (#1747)
This commit is contained in:
@@ -15,11 +15,24 @@ def test_strip_regex_text_func():
|
||||
but sometimes we want to remove the lines.
|
||||
|
||||
but 1 lines
|
||||
skip 5 lines
|
||||
really? yes man
|
||||
#/not this tries weirdly formed regex or just strings starting with /
|
||||
/not this
|
||||
but including 1234 lines
|
||||
igNORe-cAse text we dont want to keep
|
||||
but not always."""
|
||||
|
||||
ignore_lines = ["sometimes", "/\s\d{2,3}\s/", "/ignore-case text/"]
|
||||
|
||||
ignore_lines = [
|
||||
"sometimes",
|
||||
"/\s\d{2,3}\s/",
|
||||
"/ignore-case text/",
|
||||
"really?",
|
||||
"/skip \d lines/i",
|
||||
"/not"
|
||||
]
|
||||
|
||||
|
||||
fetcher = fetch_site_status.perform_site_check(datastore=False)
|
||||
stripped_content = html_tools.strip_ignore_text(test_content, ignore_lines)
|
||||
@@ -27,4 +40,10 @@ def test_strip_regex_text_func():
|
||||
assert b"but 1 lines" in stripped_content
|
||||
assert b"igNORe-cAse text" not in stripped_content
|
||||
assert b"but 1234 lines" not in stripped_content
|
||||
assert b"really" not in stripped_content
|
||||
assert b"not this" not in stripped_content
|
||||
|
||||
# Check line number reporting
|
||||
stripped_content = html_tools.strip_ignore_text(test_content, ignore_lines, mode="line numbers")
|
||||
assert stripped_content == [2, 5, 6, 7, 8, 10]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user