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)
| f | 1 | def logic_mixin_factory(mass, mass_attr_name, material, material_attr_name, float_method_name): | f | 1 | def logic_mixin_factory(mass, mass_attr_name, material, material_attr_name, float_method_name): |
| n | n | 2 | |||
| 3 | |||||
| 2 | class LogicMixin: | 4 | class LogicMixin: | ||
| 3 | 5 | ||||
| 4 | def is_a_witch(self): | 6 | def is_a_witch(self): | ||
| n | 5 | if hasattr(self,mass_attr_name) and mass == getattr(self, mass_attr_name): | n | 7 | if hasattr(self, mass_attr_name) and mass == getattr(self, mass_attr_name): |
| 6 | return "Burn her!" | 8 | return "Burn her!" | ||
| n | 7 | if hasattr(self,material_attr_name) and getattr(self, material_attr_name) == material: | n | 9 | if hasattr(self, material_attr_name) and getattr(self, material_attr_name) == material: |
| 8 | return "Burn her!" | 10 | return "Burn her!" | ||
| n | 9 | if hasattr(self,float_method_name): | n | 11 | 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!" | ||
| t | t | 14 | |||
| 12 | return LogicMixin | 15 | return LogicMixin |
| Legends | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
| |||||||||