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