| f | class Tester: | f | class Tester: |
| | | |
| n | def __init__(self, fun): | n | def __init__(self, func): |
| self.fun = fun | | self.func = func |
| | | |
| def __call__(self, suite, allowed=()): | | def __call__(self, suite, allowed=()): |
| n | has_allowed = False | n | allowed_found = False |
| has_not_allowed = False | | bad_found = False |
| for args in suite: | | for args in suite: |
| try: | | try: |
| n | self.fun(*args) | n | self.func(*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 | has_allowed = True | n | allowed_found = True |
| else: | | else: |
| n | has_not_allowed = True | n | bad_found = True |
| if has_not_allowed: | | if bad_found: |
| return 1 | | return 1 |
| t | elif has_allowed: | t | elif allowed_found: |
| return -1 | | return -1 |
| else: | | else: |
| return 0 | | return 0 |