1class LockPicker_7MI0600307:
2 def __init__(self, lock):
3 self.lock = lock
4
5 # @staticmethod
6 def unlock(self):
7
8 while True:
9 args = []
10 try:
11 if self.lock.pick(*args):
12 return True
13
14 except Exception as ex:
15 if isinstance(ex, TypeError):
16 if ex.position is None and isinstance(ex.expected, int):
17 args = [ex.position] * ex.expected
18 else:
19 args[ex.position] = ex.expected()
20 elif isinstance(ex, ValueError):
21 args[ex.position] = ex.expected
Грешка при опит за отключване:
Traceback (most recent call last):
File "/tmp/test.py", line 98, in <module>
test_unlocker(LockPicker(lock))
File "/usr/local/lib/python3.12/dist-packages/timeout_decorator/timeout_decorator.py", line 82, in new_function
return function(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/test.py", line 77, in test_unlocker
unlocker.unlock()
File "/tmp/solution.py", line None, in unlock
File "/usr/local/lib/python3.12/dist-packages/timeout_decorator/timeout_decorator.py", line 69, in handler
_raise_exception(timeout_exception, exception_message)
File "/usr/local/lib/python3.12/dist-packages/timeout_decorator/timeout_decorator.py", line 45, in _raise_exception
raise exception()
timeout_decorator.timeout_decorator.TimeoutError: 'Timed Out'
F
======================================================================
FAIL: test_picking (test.TestLockPicker.test_picking)
Ensure the lock is picked based on already stored boolean var.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 72, in test_picking
self.assertTrue(correct, "Не успя да отключиш.")
AssertionError: False is not true : Не успя да отключиш.
----------------------------------------------------------------------
Ran 1 test in 0.000s
FAILED (failures=1)
13.11.2024 15:53
13.11.2024 15:53