Become a bit stricter: do full-line pattern match, and update unit tests to capture the full error output

This commit is contained in:
Pim van Pelt
2022-03-22 15:10:40 +00:00
parent 7303adb74a
commit 7bf940be0a
6 changed files with 8 additions and 8 deletions

View File

@ -68,7 +68,7 @@ class YAMLTest(unittest.TestCase):
for m in msgs: for m in msgs:
this_msg_expected = False this_msg_expected = False
for expected in msgs_expected: for expected in msgs_expected:
if re.search(expected, m): if re.match(expected, m):
this_msg_expected = True this_msg_expected = True
break break
if not this_msg_expected: if not this_msg_expected:

View File

@ -2,8 +2,8 @@ test:
description: "MTU too small on one interface, too large on another" description: "MTU too small on one interface, too large on another"
errors: errors:
expected: expected:
- "mtu.*less than 128" - "yamale:.*mtu: 127 is less than 128"
- "mtu.*greater than 9216" - "yamale:.*mtu: 9217 is greater than 9216"
count: 2 count: 2
--- ---
interfaces: interfaces:

View File

@ -2,7 +2,7 @@ test:
description: "Interface description field mistyped" description: "Interface description field mistyped"
errors: errors:
expected: expected:
- "descr.*Unexpected element" - "yamale:.*descr: Unexpected element"
count: 1 count: 1
--- ---
interfaces: interfaces:

View File

@ -4,7 +4,7 @@ test:
expected: expected:
- "yamale: .* is not a " - "yamale: .* is not a "
- "yamale: .*: Unexpected element" - "yamale: .*: Unexpected element"
- "Length of .* is greater than 15" - "yamale: .*: Length of .* is greater than 15"
count: 13 count: 13
--- ---
interfaces: interfaces:

View File

@ -2,8 +2,8 @@ test:
description: "Two subinterfaces can't have the same encapsulation" description: "Two subinterfaces can't have the same encapsulation"
errors: errors:
expected: expected:
- "100 .* unique encapsulation" - "sub-interface .*.100 does not have unique encapsulation"
- "101 .* unique encapsulation" - "sub-interface .*.101 does not have unique encapsulation"
count: 2 count: 2
--- ---
interfaces: interfaces:

View File

@ -2,7 +2,7 @@ test:
description: "A bunch of sub-interfaces with incorrect encapsulation" description: "A bunch of sub-interfaces with incorrect encapsulation"
errors: errors:
expected: expected:
- "has invalid encapsulation" - "sub-interface .* has invalid encapsulation"
count: 2 count: 2
--- ---
interfaces: interfaces: