| 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=None): | | def __call__(self, suite, allowed=None): |
| if allowed is None: | | if allowed is None: |
| allowed = [] | | allowed = [] |
| n | allowed_tuple = tuple(allowed) | n | allowed_exceptions = tuple(allowed) |
| allowed_error_occurred = False | | has_allowed_exception = False |
| for args in suite: | | for args in suite: |
| try: | | try: |
| self.fun(*args) | | self.fun(*args) |
| n | except allowed_tuple: | n | except allowed_exceptions: |
| allowed_error_occurred = True | | has_allowed_exception = True |
| except Exception: | | except Exception: |
| return 1 | | return 1 |
| n | if allowed_error_occurred: | n | if has_allowed_exception: |
| return -1 | | return -1 |
| t | | t | else: |
| return 0 | | return 0 |