Skip to content

Commit

Permalink
Add skip test decorator to test utils
Browse files Browse the repository at this point in the history
- Currently it's duplicated on Safe services
  • Loading branch information
Uxio0 committed Nov 23, 2023
1 parent c2bee8b commit 328fa8b
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions gnosis/eth/tests/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import functools
import json
import os
from copy import deepcopy
Expand Down Expand Up @@ -74,6 +75,29 @@ def just_test_if_polygon_node() -> str:
return polygon_node_url


def skip_on(exception, reason="Test skipped due to a controlled exception"):
"""
Decorator to skip a test if an exception is raised instead of failing it
:param exception:
:param reason:
:return:
"""

def decorator_func(f):
@functools.wraps(f)
def wrapper(*args, **kwargs):
try:
# Run the test
return f(*args, **kwargs)
except exception:
pytest.skip(reason)

return wrapper

return decorator_func


# TODO Move this to EthereumClient
def send_tx(w3: Web3, tx: TxParams, account: LocalAccount) -> bytes:
tx["from"] = account.address
Expand Down

0 comments on commit 328fa8b

Please sign in to comment.