| 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=()): |
| allowed = tuple(allowed or ()) | | allowed = tuple(allowed or ()) |
| had_allowed = False | | had_allowed = 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 allowed and isinstance(e, allowed): | | if allowed and isinstance(exc, allowed): |
| had_allowed = True | | had_allowed = True |
| t | continue | t | else: |
| return 1 | | return 1 |
| return -1 if had_allowed else 0 | | return -1 if had_allowed else 0 |