1class ProtectedSection:
2
3 def __init__(self, log=(), suppress=()):
4 self.exceptions_log = log
5 self.exceptions_suppress = suppress
6 self.exception = None
7
8 def __enter__(self):
9 return self
10
11 def __exit__(self, exception_type, exception_value, _):
12 if exception_type in self.exceptions_log:
13 self.exception = exception_value
14 return True
15 if exception_type is None or exception_type in self.exceptions_suppress:
16 return True
17 return False
.F
======================================================================
FAIL: test_special_cases (test.TestSolution.test_special_cases)
Test special cases to show you that you missed something.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 128, in test_special_cases
self.assertIsNone(cm.exception)
AssertionError: ZeroDivisionError('division by zero') is not None
----------------------------------------------------------------------
Ran 2 tests in 0.001s
FAILED (failures=1)