Предизвикателства > 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    """Return a Mixin class capable of detecting witchcraft."""
 3    class WitchChecker:
 4
 5        def is_a_witch(self):
 6            """A fail-proof judge to decide if thee woman is a witch. Which she most certainly must be."""
 7            mass_attr, material_attr = getattr(self, mass_attr_name, None), getattr(self, material_attr_name, None)
 8            if mass_attr == mass or material_attr == material or getattr(self, float_method_name, None):
 9                return "Burn her!"
10            return "No, but it's a pity, cuz she looks like a witch!"
11    return WitchChecker

F
======================================================================
FAIL: test_realcase (test.TestWitchMixinFactory)
Real test for the Witch factory.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 50, in test_realcase
self.assertEqual(FloatFalse().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)

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