Skip to content

Commit a943007

Browse files
committed
test/infamy: add optional msg support to tap.py::Test.fail()
A very common pattern in our tests is: if (condition): print(f"the condition failed with {output}") test.fail() This change allows us to write: if (condition): test.fail(f"the condition failed with {output}") Signed-off-by: Joachim Wiberg <[email protected]>
1 parent a3d30eb commit a943007

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

test/infamy/tap.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@ def succeed(self):
9595
def skip(self):
9696
raise TestSkip()
9797

98-
def fail(self):
98+
def fail(self, message=None):
99+
if message:
100+
self.out.write(f"# {message}\n")
101+
self.out.flush()
99102
raise TestFail()
100103

101104

0 commit comments

Comments
 (0)