Skip to content

Commit 6378e4b

Browse files
committed
SCSTestExceptions must be raised inside with block
Signed-off-by: Katharina Trentau <[email protected]>
1 parent 024f015 commit 6378e4b

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Tests/kaas/k8s-default-storage-class/helper.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class SCSTestException(Exception):
3131
"""Raised when an Specific test did not pass"""
3232

3333
def __init__(self, *args, return_code: int):
34+
super().__init__(*args)
3435
self.return_code = return_code
3536

3637

Tests/kaas/k8s-default-storage-class/k8s-default-storage-class-check.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,13 @@ def __exit__(self, exc_type, exc_value, traceback):
261261
self.clean()
262262
if self.return_code == 0:
263263
self.return_message = "all tests passed"
264-
264+
if isinstance(exc_value, SCSTestException):
265+
# Get the return_code from the exception
266+
self.return_code = exc_value.return_code
267+
print(f"SCSTestException occurred with return_code: {self.return_code}")
268+
else:
269+
# No specific exception, handle normally
270+
print(f"Exiting the context with return_code: {self.return_code}")
265271
logger.debug(f"return_code:{self.return_code} {self.return_message}")
266272

267273
gen_sonobuoy_result_file(self.return_code, self.return_message, os.path.basename(__file__))

0 commit comments

Comments
 (0)