| Подлужный Олег 304 КФ TestFun 6633 | Татьяна Точаева, 321 группа TestFun 8077 | ||||
|---|---|---|---|---|---|
| f | 1 | class Tester: | f | 1 | class Tester: |
| 2 | 2 | ||||
| 3 | def __init__(self, fun): | 3 | def __init__(self, fun): | ||
| 4 | self.fun = fun | 4 | self.fun = fun | ||
| 5 | 5 | ||||
| 6 | def __call__(self, suite, allowed=()): | 6 | def __call__(self, suite, allowed=()): | ||
| n | 7 | has_allowed = False | n | 7 | allowed_flag = False |
| 8 | has_not_allowed = False | 8 | bad_flag = False | ||
| 9 | for args in suite: | 9 | for args_tuple in suite: | ||
| 10 | try: | 10 | try: | ||
| n | 11 | self.fun(*args) | n | 11 | self.fun(*args_tuple) |
| 12 | except Exception as e: | 12 | except Exception as e: | ||
| n | 13 | if any((isinstance(e, exc) for exc in allowed)): | n | 13 | if any((isinstance(e, exc_class) for exc_class in allowe |
| > | d)): | ||||
| 14 | has_allowed = True | 14 | allowed_flag = True | ||
| 15 | else: | 15 | else: | ||
| n | 16 | has_not_allowed = True | n | 16 | bad_flag = True |
| 17 | if has_not_allowed: | 17 | if bad_flag: | ||
| 18 | return 1 | 18 | return 1 | ||
| t | 19 | elif has_allowed: | t | 19 | elif allowed_flag: |
| 20 | return -1 | 20 | return -1 | ||
| 21 | else: | 21 | else: | ||
| 22 | return 0 | 22 | return 0 | ||
| Legends | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
| |||||||||