| f | class Tester: | f | class Tester: |
| | | |
| n | def __init__(self, func): | n | def __init__(self, fun): |
| self.func = func | | self.fun = fun |
| | | |
| def __call__(self, suite, allowed=()): | | def __call__(self, suite, allowed=()): |
| n | allowed_found = False | n | has_allowed = False |
| bad_found = False | | has_not_allowed = False |
| for args in suite: | | for args in suite: |
| try: | | try: |
| n | self.func(*args) | n | self.fun(*args) |
| except Exception as e: | | except Exception as e: |
| if any((isinstance(e, exc) for exc in allowed)): | | if any((isinstance(e, exc) for exc in allowed)): |
| n | allowed_found = True | n | has_allowed = True |
| else: | | else: |
| n | bad_found = True | n | has_not_allowed = True |
| if bad_found: | | if has_not_allowed: |
| return 1 | | return 1 |
| t | elif allowed_found: | t | elif has_allowed: |
| return -1 | | return -1 |
| else: | | else: |
| return 0 | | return 0 |