1class ProtectedSection():
2 def __init__(self, **kwargs):
3 self.log = kwargs.get("log", ())
4 self.suppress = kwargs.get("suppress", ())
5 self.exception=None
6
7 def __enter__(self):
8 return self
9
10 def __exit__(self, exc_type, exc_val):
11 if exc_type is not None:
12 if exc_type in self.log:
13 self.exception=exc_val
14 return True
15 elif exc_type in self.suppress:
16 return True
17 return None
EE
======================================================================
ERROR: test_solution (test.TestSolution.test_solution)
Test everything in a single test case. Only 100% gives a point.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 24, in test_solution
with solution.ProtectedSection() as cm:
TypeError: ProtectedSection.__exit__() takes 3 positional arguments but 4 were given
======================================================================
ERROR: 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 125, in test_special_cases
x = 1 / 0
~~^~~
ZeroDivisionError: division by zero
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/tmp/test.py", line 124, in test_special_cases
with protected_section as cm:
TypeError: ProtectedSection.__exit__() takes 3 positional arguments but 4 were given
----------------------------------------------------------------------
Ran 2 tests in 0.001s
FAILED (errors=2)
08.11.2024 12:28
08.11.2024 12:29
08.11.2024 12:28