1class LockPicker_4MI0600199:
 2    def __init__(self, lock):
 3        self.lock = lock
 4        self.attempts = []
 5
 6    def unlock(self):
 7        args = []
 8
 9        while True:
10            try:
11                self.lock.pick(*args)
12                self.attempts.append(args.copy())
13                return  
14            except TypeError as e:
15                if e.position is None:
16                    args = [None] * e.expected
17                else: 
18                    args[e.position - 1] = self._get_default_value(e.expected)
19            except ValueError as e:
20                args[e.position - 1] = e.expected
21
22    def _get_default_value(self, expected_type):
23        if expected_type is int:
24            return 0
25        elif expected_type is str:
26            return ''
27        elif expected_type is float:
28            return 0.0
29        elif expected_type is list:
30            return []
31        elif expected_type is dict:
32            return {}
33        elif expected_type is bool:
34            return False
35        else:
36            return None
Грешка при опит за отключване:
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 11, in unlock
    self.lock.pick(*args)
  File "/tmp/test.py", line 55, in pick
    raise LockTypeError("You shall not pass!", position, type(slot))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  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 18:48
13.11.2024 18:39