Move the output around - first print the unexpected messages, only then fail the assertions
This commit is contained in:
12
tests.py
12
tests.py
@ -58,12 +58,6 @@ class YAMLTest(unittest.TestCase):
|
||||
|
||||
v = Validator(schema=self.yaml_schema)
|
||||
rv, msgs = v.validate(cfg)
|
||||
count = 0
|
||||
if 'test' in unittest and 'errors' in unittest['test'] and 'count' in unittest['test']['errors']:
|
||||
count = unittest['test']['errors']['count']
|
||||
if len(msgs) != count:
|
||||
print(msgs, file=sys.stderr)
|
||||
self.assertEqual(len(msgs), count)
|
||||
|
||||
msgs_unexpected = 0
|
||||
msgs_expected = []
|
||||
@ -80,6 +74,12 @@ class YAMLTest(unittest.TestCase):
|
||||
if not this_msg_expected:
|
||||
print("%s: Unexpected message: %s" % (self.yaml_filename, m), file=sys.stderr)
|
||||
fail = True
|
||||
|
||||
count = 0
|
||||
if 'test' in unittest and 'errors' in unittest['test'] and 'count' in unittest['test']['errors']:
|
||||
count = unittest['test']['errors']['count']
|
||||
|
||||
self.assertEqual(len(msgs), count)
|
||||
self.assertFalse(fail)
|
||||
|
||||
return
|
||||
|
@ -1,22 +0,0 @@
|
||||
test:
|
||||
description: "The length of the generated child LCP name is too long"
|
||||
errors:
|
||||
expected:
|
||||
- "sub-interface .* has LCP with too long name"
|
||||
count: 1
|
||||
---
|
||||
interfaces:
|
||||
GigabitEthernet1/0/0:
|
||||
lcp: "e01234"
|
||||
sub-interfaces:
|
||||
100:
|
||||
description: "Dot1Q subinterface"
|
||||
encapsulation:
|
||||
dot1q: 1234
|
||||
101:
|
||||
description: "QinQ subinterface"
|
||||
addresses: [ 192.0.2.1/24 ]
|
||||
encapsulation:
|
||||
dot1q: 1234
|
||||
inner-dot1q: 2345
|
||||
|
Reference in New Issue
Block a user