| 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=()): |
| had_allowed_exception = False | | had_allowed_exception = False |
| n | for test_case in suite: | n | for args in suite: |
| try: | | try: |
| t | self.fun(*test_case) | t | self.fun(*args) |
| except Exception as e: | | except Exception as e: |
| if allowed and isinstance(e, tuple(allowed)): | | if allowed and isinstance(e, tuple(allowed)): |
| had_allowed_exception = True | | had_allowed_exception = True |
| else: | | else: |
| return 1 | | return 1 |
| if had_allowed_exception: | | if had_allowed_exception: |
| return -1 | | return -1 |
| return 0 | | return 0 |