1def logic_mixin_factory(mass, mass_attr_name, material, material_attr_name, float_method_name):
2 class WitchMixin:
3
4 def is_a_witch(self):
5 if hasattr(self, mass_attr_name) and getattr(self, mass_attr_name) == mass:
6 return "Burn her!"
7 elif hasattr(self, material_attr_name) and getattr(self, material_attr_name) == material:
8 return "Burn her!"
9 elif hasattr(self, float_method_name) and callable(getattr(self, float_method_name)):
10 return "Burn her!"
11 else:
12 return "No, but it's a pity, cuz she looks like a witch!"
13
14
15 return WitchMixin
.
----------------------------------------------------------------------
Ran 1 test in 0.000s
OK
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 | 2 | class WitchMixin(): | n | 2 | class WitchMixin: |
3 | 3 | ||||
4 | def is_a_witch(self): | 4 | def is_a_witch(self): | ||
5 | if hasattr(self, mass_attr_name) and getattr(self, mass_attr_name) == mass: | 5 | if hasattr(self, mass_attr_name) and getattr(self, mass_attr_name) == mass: | ||
6 | return "Burn her!" | 6 | return "Burn her!" | ||
7 | elif hasattr(self, material_attr_name) and getattr(self, material_attr_name) == material: | 7 | elif hasattr(self, material_attr_name) and getattr(self, material_attr_name) == material: | ||
8 | return "Burn her!" | 8 | return "Burn her!" | ||
9 | elif hasattr(self, float_method_name) and callable(getattr(self, float_method_name)): | 9 | elif hasattr(self, float_method_name) and callable(getattr(self, float_method_name)): | ||
10 | return "Burn her!" | 10 | return "Burn her!" | ||
11 | else: | 11 | else: | ||
12 | return "No, but it's a pity, cuz she looks like a witch!" | 12 | return "No, but it's a pity, cuz she looks like a witch!" | ||
13 | 13 | ||||
14 | 14 | ||||
15 | return WitchMixin | 15 | return WitchMixin | ||
t | 16 | t |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|