Skip to content

Commit 9d9e099

Browse files
committed
test/infamy: slight improvement to tap.py::Test.__exit__()
Before this change: ok 2 - Configure basic end-device firewall not ok 3 - Verify unused interface assigned to default zone # Exiting (2025-09-25 11:33:00) # Traceback (most recent call last): # File "/home/jocke/src/x-misc/test/./case/infix_firewall/basic/test.py", line 127, in <module> # assert unused_if not in public_zone["interface"], \ # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ # AssertionError: Unused interface e4 should be in default zone 'public', got interfaces: ['e2', 'e3', 'e5', 'e7', 'e8'] After this change: ok 2 - Configure basic end-device firewall not ok 3 - Verify unused interface assigned to default zone # Exiting (2025-09-25 11:35:00) # File "/home/jocke/src/x-misc/test/./case/infix_firewall/basic/test.py", line 127, in <module> # assert unused_if not in public_zone["interface"], \ # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ # Unused interface e4 should be in default zone 'public', got interfaces: ['e2', 'e3', 'e5', 'e7', 'e8'] Slightly shorter and arguably easier to read for a non-pythonic human. Signed-off-by: Joachim Wiberg <[email protected]>
1 parent a943007 commit 9d9e099

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

test/infamy/tap.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def __enter__(self):
3030
self.out.flush()
3131
return self
3232

33-
def __exit__(self, _, e, __):
33+
def __exit__(self, t, e, tb):
3434
now = datetime.datetime.now().strftime("%F %T")
3535
self.out.write(f"# Exiting ({now})\n")
3636
self.out.flush()
@@ -40,12 +40,16 @@ def __exit__(self, _, e, __):
4040
if not e:
4141
self._not_ok("Missing explicit test result\n")
4242
else:
43-
if type(e) in (TestPass, TestSkip):
43+
if t in (TestPass, TestSkip):
4444
self.out.write(f"{self.steps}..{self.steps}\n")
4545
self.out.flush()
4646
raise SystemExit(0)
47-
48-
traceback.print_exception(e, file=self.commenter)
47+
if t is AssertionError:
48+
traceback.print_tb(tb, file=self.commenter)
49+
self.out.write(f"{str(e)}\n")
50+
self.out.flush()
51+
else:
52+
traceback.print_exception(e, file=self.commenter)
4953

5054
if type(e) is subprocess.CalledProcessError:
5155
print("Failing subprocess stdout:\n", e.stdout)

0 commit comments

Comments
 (0)