| 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=()): |
| n | al_ex = tuple(allowed) | n | allowed_exceptions = tuple(allowed) |
| | | has_allowed_exceptions = False |
| unallowed_ex_fl = False | | has_unallowed_exceptions = False |
| al_ex_fl = False | | |
| for i in suite: | | for params in suite: |
| try: | | try: |
| n | self.fun(*i) | n | self.fun(*params) |
| except al_ex: | | except allowed_exceptions: |
| al_ex_fl = True | | has_allowed_exceptions = True |
| except Exception: | | except Exception: |
| n | unallowed_ex_fl = True | n | has_unallowed_exceptions = True |
| else: | | |
| continue | | |
| if unallowed_ex_fl: | | if has_unallowed_exceptions: |
| return 1 | | return 1 |
| t | elif al_ex_fl: | t | elif has_allowed_exceptions: |
| return -1 | | return -1 |
| else: | | else: |
| return 0 | | return 0 |