|
6 | 6 | PATTERN = BUILTIN_REGEXES["fail"][0]
|
7 | 7 | regex = re.compile(PATTERN)
|
8 | 8 |
|
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 |
| - |
45 | 9 |
|
46 | 10 | # Positive test cases: strings that should trigger a match.
|
47 | 11 | @pytest.mark.parametrize(
|
48 | 12 | "text",
|
49 | 13 | [
|
50 |
| - # Existing keywords (with various forms) |
51 | 14 | "error",
|
52 | 15 | "Error",
|
53 | 16 | "err",
|
|
100 | 63 | "abort",
|
101 | 64 | "aborted",
|
102 | 65 | "aborting",
|
103 |
| - # New keywords |
104 | 66 | "panic",
|
105 | 67 | "crit",
|
106 | 68 | "critical",
|
@@ -147,7 +109,6 @@ def test_positive_matches(text):
|
147 | 109 | "timepiece", # false positive check
|
148 | 110 | "expiredd", # extra letter at the end
|
149 | 111 | "malformedly", # extra suffix
|
150 |
| - # New keywords with extra letters (should not match) |
151 | 112 | "panicking", # extra suffix, should not match exactly "panic"
|
152 | 113 | "critiqued", # false positive for "crit"
|
153 | 114 | "alerting", # false positive for "alert"
|
|
0 commit comments