Skip to content

Commit fa346f7

Browse files
author
MarcoFalke
committed
test: Move error string into exception
This is normally expected and also less code.
1 parent fa19861 commit fa346f7

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

test/functional/tool_utils.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,9 @@ def test_one(self, testObj):
6464
with open(self.testcase_dir / outputFn, encoding="utf8") as f:
6565
outputData = f.read()
6666
if not outputData:
67-
logging.error("Output data missing for " + outputFn)
68-
raise Exception
67+
raise Exception(f"Output data missing for {outputFn}")
6968
if not outputType:
70-
logging.error("Output file %s does not have a file extension" % outputFn)
71-
raise Exception
69+
raise Exception(f"Output file {outputFn} does not have a file extension")
7270

7371
# Run the test
7472
res = subprocess.run(execrun, capture_output=True, text=True, input=inputData)
@@ -107,20 +105,17 @@ def test_one(self, testObj):
107105
if "return_code" in testObj:
108106
wantRC = testObj['return_code']
109107
if res.returncode != wantRC:
110-
logging.error(f"Return code mismatch for {outputFn}; res: {str(res)}")
111-
raise Exception
108+
raise Exception(f"Return code mismatch for {outputFn}; res: {str(res)}")
112109

113110
if "error_txt" in testObj:
114111
want_error = testObj["error_txt"]
115112
# A partial match instead of an exact match makes writing tests easier
116113
# and should be sufficient.
117114
if want_error not in res.stderr:
118-
logging.error(f"Error mismatch:\nExpected: {want_error}\nReceived: {res.stderr.rstrip()}\nres: {str(res)}")
119-
raise Exception
115+
raise Exception(f"Error mismatch:\nExpected: {want_error}\nReceived: {res.stderr.rstrip()}\nres: {str(res)}")
120116
else:
121117
if res.stderr:
122-
logging.error(f"Unexpected error received: {res.stderr.rstrip()}\nres: {str(res)}")
123-
raise Exception
118+
raise Exception(f"Unexpected error received: {res.stderr.rstrip()}\nres: {str(res)}")
124119

125120

126121
def parse_output(a, fmt):

0 commit comments

Comments
 (0)