| f | class Tester: | f | class Tester: |
| | | |
| def __init__(self, fun): | | def __init__(self, fun): |
| self.fun = fun | | self.fun = fun |
| | | |
| n | def __call__(self, suite, allowed=()): | n | def __call__(self, suite, allowed: tuple=()): |
| allowed = tuple(allowed) | | allowed_tuple = tuple(allowed) |
| exc = False | | any_exceptions = False |
| unal = False | | any_disallowed = False |
| for args in suite: | | for args in suite: |
| try: | | try: |
| self.fun(*args) | | self.fun(*args) |
| except Exception as e: | | except Exception as e: |
| n | exc = True | n | any_exceptions = True |
| if not isinstance(e, allowed): | | if not isinstance(e, allowed_tuple): |
| unal = True | | any_disallowed = True |
| break | | if any_disallowed: |
| if unal: | | |
| return 1 | | return 1 |
| t | if exc: | t | if any_exceptions: |
| return -1 | | return -1 |
| return 0 | | return 0 |