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

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)

Дискусия
История

f1def  logic_mixin_factory(mass, mass_attr_name, material, material_attr_name, float_method_name):f1def  logic_mixin_factory(mass, mass_attr_name, material, material_attr_name, float_method_name):
nn2 
3 
2    class LogicMixin:4    class LogicMixin:
3         5         
4         def is_a_witch(self):6         def is_a_witch(self):
n5              if hasattr(self,mass_attr_name) and  mass == getattr(self, mass_attr_name):n7              if hasattr(self, mass_attr_name) and  mass == getattr(self, mass_attr_name):
6                    return "Burn her!"8                    return "Burn her!"
n7              if hasattr(self,material_attr_name) and getattr(self, material_attr_name) == material:n9              if hasattr(self, material_attr_name) and getattr(self, material_attr_name) == material:
8                    return "Burn her!"10                    return "Burn her!"
n9              if hasattr(self,float_method_name):n11              if hasattr(self, float_method_name):
10                    return "Burn her!"12                    return "Burn her!"
11              return "No, but it's a pity, cuz she looks like a witch!"13              return "No, but it's a pity, cuz she looks like a witch!"
tt14         
12    return LogicMixin     15    return LogicMixin     
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op