1class ProtectedSection:
2 def __init__(self, log=(), suppress=()):
3 self.exception = None
4 self.log = log
5 self.suppress = suppress
6
7 def __enter__(self):
8 return self
9
10 def __exit__(self, exc_type, exc_val, exc_tb):
11 if exc_type is None:
12 return True
13 if exc_type in self.log:
14 self.exception = exc_val
15 return True
16 if exc_type in self.suppress:
17 return True
18 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)