Предизвикателства > 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 is_a_witch(self):
4            return "Burn her!" if any(
5                getattr(self, attr, None) == val
6                for attr, val in [(mass_attr_name, mass), (material_attr_name, material), (float_method_name, None)]
7            ) else "No, but it's a pity, cuz she looks like a witch."
8
9    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)

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