mirror of
https://github.com/kernelkit/infix.git
synced 2026-08-02 22:03:01 +02:00
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 <troglobit@gmail.com>
This commit is contained in:
+8
-4
@@ -30,7 +30,7 @@ class Test:
|
||||
self.out.flush()
|
||||
return self
|
||||
|
||||
def __exit__(self, _, e, __):
|
||||
def __exit__(self, t, e, tb):
|
||||
now = datetime.datetime.now().strftime("%F %T")
|
||||
self.out.write(f"# Exiting ({now})\n")
|
||||
self.out.flush()
|
||||
@@ -40,12 +40,16 @@ class Test:
|
||||
if not e:
|
||||
self._not_ok("Missing explicit test result\n")
|
||||
else:
|
||||
if type(e) in (TestPass, TestSkip):
|
||||
if t in (TestPass, TestSkip):
|
||||
self.out.write(f"{self.steps}..{self.steps}\n")
|
||||
self.out.flush()
|
||||
raise SystemExit(0)
|
||||
|
||||
traceback.print_exception(e, file=self.commenter)
|
||||
if t is AssertionError:
|
||||
traceback.print_tb(tb, file=self.commenter)
|
||||
self.out.write(f"{str(e)}\n")
|
||||
self.out.flush()
|
||||
else:
|
||||
traceback.print_exception(e, file=self.commenter)
|
||||
|
||||
if type(e) is subprocess.CalledProcessError:
|
||||
print("Failing subprocess stdout:\n", e.stdout)
|
||||
|
||||
Reference in New Issue
Block a user