Skip to content

Commit 2d1dc8d

Browse files
committed
Fix the unit tests for the "fail" regex
Use the pattern from the klp module
1 parent f5ae5f6 commit 2d1dc8d

File tree

1 file changed

+0
-39
lines changed

1 file changed

+0
-39
lines changed

tests/test_fail_regex.py

-39
Original file line numberDiff line numberDiff line change
@@ -6,48 +6,11 @@
66
PATTERN = BUILTIN_REGEXES["fail"][0]
77
regex = re.compile(PATTERN)
88

9-
import re
10-
import pytest
11-
12-
# Enhanced regex incorporating additional keywords.
13-
PATTERN = (
14-
r"(?i)\b(?:"
15-
r"err(?:or|r)?|" # error, err
16-
r"fail(?:ure|ed|ing)?|" # fail, failure, failed, failing
17-
r"den(?:y|ied)|" # deny, denied
18-
r"invalid|" # invalid
19-
r"time(?:-?\s*out|d\s*out|out)|" # timeout, time out, timed out, time-out
20-
r"timout|" # common misspelling
21-
r"exception|" # exception
22-
r"blocked|" # blocked
23-
r"expir(?:ed|ing|ation|e)?|" # expire, expired, expiring, expiration
24-
r"reject(?:ed|ing|ion)?|" # reject, rejected, rejecting, rejection
25-
r"unauthoriz(?:e(?:d|ation)?|ed|ation)?|" # unauthorized variants
26-
r"unauth|" # shorthand for unauthorized
27-
r"forbidden|" # forbidden
28-
r"corrupt(?:ed|ion)?|" # corrupt, corrupted, corruption
29-
r"malform(?:ed|ation)?|" # malform, malformed, malformation
30-
r"disconnect(?:ed|ion)?|" # disconnect, disconnected, disconnection
31-
r"unreachable|" # unreachable
32-
r"violat(?:ed|ion|e)?|" # violate, violated, violation
33-
r"blacklist(?:ed|ing)?|" # blacklist, blacklisted, blacklisting
34-
r"crash(?:ed|ing)?|" # crash, crashed, crashing
35-
r"abort(?:ed|ing)?|" # abort, aborted, aborting
36-
r"panic|" # panic
37-
r"crit(?:ical)?|" # crit or critical
38-
r"alert|" # alert
39-
r"fatal|" # fatal
40-
r"emerg(?:ency)?" # emerg or emergency
41-
r")\b"
42-
)
43-
regex = re.compile(PATTERN)
44-
459

4610
# Positive test cases: strings that should trigger a match.
4711
@pytest.mark.parametrize(
4812
"text",
4913
[
50-
# Existing keywords (with various forms)
5114
"error",
5215
"Error",
5316
"err",
@@ -100,7 +63,6 @@
10063
"abort",
10164
"aborted",
10265
"aborting",
103-
# New keywords
10466
"panic",
10567
"crit",
10668
"critical",
@@ -147,7 +109,6 @@ def test_positive_matches(text):
147109
"timepiece", # false positive check
148110
"expiredd", # extra letter at the end
149111
"malformedly", # extra suffix
150-
# New keywords with extra letters (should not match)
151112
"panicking", # extra suffix, should not match exactly "panic"
152113
"critiqued", # false positive for "crit"
153114
"alerting", # false positive for "alert"

0 commit comments

Comments
 (0)