Предизвикателства > She's a witch! > Решения > Решението на Даниела Георгиева

Резултати
0 точки от тестове
0 точки от учител

0 точки общо

0 успешни теста
1 неуспешни теста
Код

 1def logic_mixin_factory(mass, mass_attr_name, material, material_attr_name, float_method_name):
 2    class LogicMixin:
 3        def __init__(self):
 4            pass
 5        
 6        def is_a_witch(self):
 7            str_is_a_witch = "Burn her!"
 8            str_not_witch = "No, but it's a pity, cuz she looks like a witch!"
 9            try: 
10                object.__getattribute__(self, mass_attr_name) == mass
11            except AttributeError:
12                return str_is_a_witch
13            try:
14                object.__getattribute__(self, material_attr_name) == material
15            except AttributeError:
16                return str_is_a_witch
17            try:
18                callable(object.__getattribute__(self, float_method_name))
19            except:
20                return AttributeError
21            else:
22                return str_not_witch
23    
24    return LogicMixin

F
======================================================================
FAIL: test_realcase (test.TestWitchMixinFactory)
Real test for the Witch factory.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 30, in test_realcase
self.assertEqual(Nothing().is_a_witch(), self.RESULT_FALSE)
AssertionError: 'Burn her!' != "No, but it's a pity, cuz she looks like a witch!"
- Burn her!
+ No, but it's a pity, cuz she looks like a witch!

----------------------------------------------------------------------
Ran 1 test in 0.000s

FAILED (failures=1)

Дискусия
Даниела Георгиева
10.11.2023 18:03

На ред 19 трябва да е: except AttributeError: return str_is_a_witch
История
Това решение има само една версия.