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