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