- Коректно
- 5 успешни тест(а)
- 0 неуспешни тест(а)
..... ---------------------------------------------------------------------- Ran 5 tests in 0.077s OK
Срокът за предаване на решения е отминал
Дислексията е "затруднение с лексиката, предимно при четене и писане". Освен това определение, явно дислексията е толкова непонятна дори и на учените, че всяко друго описание би било или подвеждащо или outright offensive за хората с дислексия. И не че се опитваме да сме политически коректни, но така или иначе точната дефиниция на явлението е без значение за нашето предизвикателство. That being said:
Искаме да направим контекстния мениджър Dyslexic, който да ни позволява да намираме атрибути на даден обект, дори да търсим с разместени букви (едно от проявленията на дислексията).
В случай, че дори и с разместване на буквите не може да бъде намерен такъв атрибут, искаме да възбудим грешка AttributeError със следния текст:
<The name of the class> object has no dyslexic attributes <the attribute searched for> (като очевидно двете неща в <> са плейсхолдъри).
class Baba:
abc = 5
baba = Baba()
with Dyslexic(baba) as dyslexic_baba:
print(dyslexic_baba.abc) # 5
print(dyslexic_baba.bac) # 5
print(dyslexic_baba.cab) # 5
print(dyslexic_baba.notreal) # AttributeError: Baba object has no dyslexic attributes notreal
baba има както атрибут abc, така и bca, а ние търсим baba.cab - няма значение кое ще се върне първо
baba
..... ---------------------------------------------------------------------- Ran 5 tests in 0.077s OK
..... ---------------------------------------------------------------------- Ran 5 tests in 0.055s OK
..... ---------------------------------------------------------------------- Ran 5 tests in 0.061s OK
E.E.E
======================================================================
ERROR: test_attribute_not_found (test.TestDyslexicCM)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
AttributeError: 'list' object attribute 'append' is read-only
======================================================================
ERROR: test_with_builtin (test.TestDyslexicCM)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
AttributeError: 'range' object attribute 'count' is read-only
======================================================================
ERROR: test_with_function_call (test.TestDyslexicCM)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
AttributeError: 'list' object attribute 'append' is read-only
----------------------------------------------------------------------
Ran 5 tests in 0.058s
FAILED (errors=3)
..... ---------------------------------------------------------------------- Ran 5 tests in 0.071s OK
E....
======================================================================
ERROR: test_attribute_not_found (test.TestDyslexicCM)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
solution.AttributeError: list object has no dyslexic attributes no_such
----------------------------------------------------------------------
Ran 5 tests in 0.058s
FAILED (errors=1)
F....
======================================================================
FAIL: test_attribute_not_found (test.TestDyslexicCM)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
AssertionError: 'list has no dyslexic attributes no_such' != 'list object has no dyslexic attributes no_such'
- list has no dyslexic attributes no_such
+ list object has no dyslexic attributes no_such
? +++++++
----------------------------------------------------------------------
Ran 5 tests in 0.064s
FAILED (failures=1)
..... ---------------------------------------------------------------------- Ran 5 tests in 0.068s OK
..... ---------------------------------------------------------------------- Ran 5 tests in 0.055s OK
E.EEE
======================================================================
ERROR: test_attribute_not_found (test.TestDyslexicCM)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
AttributeError: 'list' object attribute 'clear' is read-only
======================================================================
ERROR: test_with_builtin (test.TestDyslexicCM)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
TypeError: range expected at least 1 argument, got 0
======================================================================
ERROR: test_with_custom_class (test.TestDyslexicCM)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
AttributeError: Couple object has no dyslexic attributes opsish
======================================================================
ERROR: test_with_function_call (test.TestDyslexicCM)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
raise result
AttributeError: 'list' object attribute 'clear' is read-only
----------------------------------------------------------------------
Ran 5 tests in 0.098s
FAILED (errors=4)
..... ---------------------------------------------------------------------- Ran 5 tests in 0.061s OK
..... ---------------------------------------------------------------------- Ran 5 tests in 0.060s OK
5
5
5
Baba object has no dyslexic attributes notreal
File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 114, in main
loaded_test = importlib.import_module('test', test_module)
File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/tmp/d20221123-4144380-1u4vn3/test.py", line 2, in <module>
from solution import Dyslexic
File "/tmp/d20221123-4144380-1u4vn3/solution.py", line 28, in <module>
print(dyslexic_baba.notreal) # AttributeError: Baba object has no dyslexic attributes notreal
File "/tmp/d20221123-4144380-1u4vn3/solution.py", line 17, in __getattr__
raise AttributeError(f"Baba object has no dyslexic attributes {item}")
..... ---------------------------------------------------------------------- Ran 5 tests in 0.053s OK