Предизвикателства > 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
 3    class MixinClass:
 4
 5        def float_method_name():
 6            pass
 7
 8        def is_a_witch(self):
 9            if hasattr(self, 'mass_attr_name') and getattr(self, 'mass_attr_name') == mass:
10                return "Burn her!"
11            elif hasattr(self, 'material_attr_name') and getattr(self, 'material_attr_name') == material:
12                return "Burn her!"
13            elif hasattr(self, float_method_name) and callable(self.float_method_name):
14                return "Burn her!"
15            else:
16                return "No, but it's a pity, cuz she looks like a witch!"
17            
18    return MixinClass

F
======================================================================
FAIL: test_realcase (test.TestWitchMixinFactory)
Real test for the Witch factory.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 34, in test_realcase
self.assertEqual(MassTrue().is_a_witch(), self.RESULT_TRUE)
AssertionError: "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!
+ Burn her!

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

FAILED (failures=1)

Дискусия
История
Това решение има само една версия.