1class LockPicker_1MI0600289():
2 def __init__(self, lock):
3 self.lock = lock
4
5 def unlock(self):
6 args = []
7 while True:
8 try:
9 self.lock.pick(*args)
10 #no error was raised
11 break
12 except TypeError as exc:
13 if exc.position is None:
14 #needs to expand
15 while len(*args) < exc.expected:
16 args.append(None)
17 else:
18 #change type
19 args[exc.position - 1] = exc.expected(args[exc.position - 1])
20 except ValueError as exc:
21 #change element
22 args[exc.position - 1] = exc.expected
23
24
Грешка при опит за отключване:
Traceback (most recent call last):
File "/tmp/solution.py", line 9, in unlock
self.lock.pick(*args)
File "/tmp/test.py", line 50, in pick
raise LockTypeError("This is a different kind of lock.",
test.LockTypeError: This is a different kind of lock.
During handling of the above exception, another exception occurred:
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 15, in unlock
while len(*args) < exc.expected:
^^^^^^^^^^
TypeError: len() takes exactly one argument (0 given)
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)
f | 1 | class LockPicker_1MI0600289(): | f | 1 | class LockPicker_1MI0600289(): |
2 | def __init__(self, lock): | 2 | def __init__(self, lock): | ||
3 | self.lock = lock | 3 | self.lock = lock | ||
4 | 4 | ||||
5 | def unlock(self): | 5 | def unlock(self): | ||
6 | args = [] | 6 | args = [] | ||
7 | while True: | 7 | while True: | ||
8 | try: | 8 | try: | ||
9 | self.lock.pick(*args) | 9 | self.lock.pick(*args) | ||
10 | #no error was raised | 10 | #no error was raised | ||
11 | break | 11 | break | ||
12 | except TypeError as exc: | 12 | except TypeError as exc: | ||
13 | if exc.position is None: | 13 | if exc.position is None: | ||
14 | #needs to expand | 14 | #needs to expand | ||
t | 15 | if len(*args) < exc.expected: | t | 15 | while len(*args) < exc.expected: |
16 | args.append(0) | 16 | args.append(None) | ||
17 | else: | 17 | else: | ||
18 | #change type | 18 | #change type | ||
19 | args[exc.position - 1] = exc.expected(args[exc.position - 1]) | 19 | args[exc.position - 1] = exc.expected(args[exc.position - 1]) | ||
20 | except ValueError as exc: | 20 | except ValueError as exc: | ||
21 | #change element | 21 | #change element | ||
22 | args[exc.position - 1] = exc.expected | 22 | args[exc.position - 1] = exc.expected | ||
23 | 23 | ||||
24 | 24 |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
f | 1 | class LockPicker_1MI0600289(): | f | 1 | class LockPicker_1MI0600289(): |
2 | def __init__(self, lock): | 2 | def __init__(self, lock): | ||
3 | self.lock = lock | 3 | self.lock = lock | ||
4 | 4 | ||||
5 | def unlock(self): | 5 | def unlock(self): | ||
6 | args = [] | 6 | args = [] | ||
7 | while True: | 7 | while True: | ||
8 | try: | 8 | try: | ||
9 | self.lock.pick(*args) | 9 | self.lock.pick(*args) | ||
10 | #no error was raised | 10 | #no error was raised | ||
11 | break | 11 | break | ||
12 | except TypeError as exc: | 12 | except TypeError as exc: | ||
13 | if exc.position is None: | 13 | if exc.position is None: | ||
14 | #needs to expand | 14 | #needs to expand | ||
15 | if len(*args) < exc.expected: | 15 | if len(*args) < exc.expected: | ||
16 | args.append(0) | 16 | args.append(0) | ||
t | 17 | #needs to shrim | t | ||
18 | else: | ||||
19 | args = args[:exc.position + 1] | ||||
20 | else: | 17 | else: | ||
21 | #change type | 18 | #change type | ||
22 | args[exc.position - 1] = exc.expected(args[exc.position - 1]) | 19 | args[exc.position - 1] = exc.expected(args[exc.position - 1]) | ||
23 | except ValueError as exc: | 20 | except ValueError as exc: | ||
24 | #change element | 21 | #change element | ||
25 | args[exc.position - 1] = exc.expected | 22 | args[exc.position - 1] = exc.expected | ||
26 | 23 | ||||
27 | 24 |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
f | 1 | class LockPicker_1MI0600289(): | f | 1 | class LockPicker_1MI0600289(): |
2 | def __init__(self, lock): | 2 | def __init__(self, lock): | ||
3 | self.lock = lock | 3 | self.lock = lock | ||
4 | 4 | ||||
t | 5 | def unlock(self, *args): | t | 5 | def unlock(self): |
6 | args = [] | ||||
6 | while True: | 7 | while True: | ||
7 | try: | 8 | try: | ||
8 | self.lock.pick(*args) | 9 | self.lock.pick(*args) | ||
9 | #no error was raised | 10 | #no error was raised | ||
10 | break | 11 | break | ||
11 | except TypeError as exc: | 12 | except TypeError as exc: | ||
12 | if exc.position is None: | 13 | if exc.position is None: | ||
13 | #needs to expand | 14 | #needs to expand | ||
14 | if len(*args) < exc.expected: | 15 | if len(*args) < exc.expected: | ||
15 | args.append(0) | 16 | args.append(0) | ||
16 | #needs to shrim | 17 | #needs to shrim | ||
17 | else: | 18 | else: | ||
18 | args = args[:exc.position + 1] | 19 | args = args[:exc.position + 1] | ||
19 | else: | 20 | else: | ||
20 | #change type | 21 | #change type | ||
21 | args[exc.position - 1] = exc.expected(args[exc.position - 1]) | 22 | args[exc.position - 1] = exc.expected(args[exc.position - 1]) | ||
22 | except ValueError as exc: | 23 | except ValueError as exc: | ||
23 | #change element | 24 | #change element | ||
24 | args[exc.position - 1] = exc.expected | 25 | args[exc.position - 1] = exc.expected | ||
25 | 26 | ||||
26 | 27 |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
t | 1 | class LockPicker_FN1MI0600289(): | t | 1 | class LockPicker_1MI0600289(): |
2 | def __init__(self, lock): | 2 | def __init__(self, lock): | ||
3 | self.lock = lock | 3 | self.lock = lock | ||
4 | 4 | ||||
5 | def unlock(self, *args): | 5 | def unlock(self, *args): | ||
6 | while True: | 6 | while True: | ||
7 | try: | 7 | try: | ||
8 | self.lock.pick(*args) | 8 | self.lock.pick(*args) | ||
9 | #no error was raised | 9 | #no error was raised | ||
10 | break | 10 | break | ||
11 | except TypeError as exc: | 11 | except TypeError as exc: | ||
12 | if exc.position is None: | 12 | if exc.position is None: | ||
13 | #needs to expand | 13 | #needs to expand | ||
14 | if len(*args) < exc.expected: | 14 | if len(*args) < exc.expected: | ||
15 | args.append(0) | 15 | args.append(0) | ||
16 | #needs to shrim | 16 | #needs to shrim | ||
17 | else: | 17 | else: | ||
18 | args = args[:exc.position + 1] | 18 | args = args[:exc.position + 1] | ||
19 | else: | 19 | else: | ||
20 | #change type | 20 | #change type | ||
21 | args[exc.position - 1] = exc.expected(args[exc.position - 1]) | 21 | args[exc.position - 1] = exc.expected(args[exc.position - 1]) | ||
22 | except ValueError as exc: | 22 | except ValueError as exc: | ||
23 | #change element | 23 | #change element | ||
24 | args[exc.position - 1] = exc.expected | 24 | args[exc.position - 1] = exc.expected | ||
25 | 25 | ||||
26 | 26 |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
13.11.2024 18:49