Skip to content

Commit

Permalink
improvement(decorator): not raise error event by silence decorator
Browse files Browse the repository at this point in the history
There are cases when it is not needed to send error event from silence
decorator. It just needs to silence the failure and keed its info in the log
  • Loading branch information
juliayakovlev authored and fruch committed Dec 9, 2024
1 parent 5278049 commit ca9d4de
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions sdcm/tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,11 @@ def my_method(self):
test = None
name: str = None

def __init__(self, parent=None, name: str = None, verbose: bool = False):
def __init__(self, parent=None, name: str = None, verbose: bool = False, raise_error_event=True):
self.parent = parent
self.name = name
self.verbose = verbose
self.raise_error_event = raise_error_event
self.log = logging.getLogger(self.__class__.__name__)

def __enter__(self):
Expand Down Expand Up @@ -259,8 +260,10 @@ def __exit__(self, exc_type, exc_val, exc_tb):
self._store_test_result(self.parent, exc_val, exc_tb, self.name)
return True

@staticmethod
def _store_test_result(parent, exc_val, exc_tb, name):
def _store_test_result(self, parent, exc_val, exc_tb, name):
if not self.raise_error_event:
return

TestFrameworkEvent(
source=parent.__class__.__name__,
source_method=name,
Expand Down

0 comments on commit ca9d4de

Please sign in to comment.