1def logic_mixin_factory(mass, mass_attr_name, material, material_attr_name, float_method_name):
2
3
4 class Mixin:
5 def is_a_witch(self):
6 try:
7 self.__getattribute__(mass_attr_name) == mass
8 return 'Burn her!'
9 except AttributeError:
10 pass
11 try:
12 self.__getattribute__(material_attr_name) == material
13 return 'Burn her!'
14 except AttributeError:
15 pass
16 try:
17 self.__getattribute__(float_method_name)
18 return 'Burn her!'
19 except AttributeError:
20 pass
21
22 return 'No, but it\'s a pity, cuz she looks like a witch!'
23
24
25 return Mixin
26
27
F
======================================================================
FAIL: test_realcase (test.TestWitchMixinFactory)
Real test for the Witch factory.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 38, in test_realcase
self.assertEqual(MassFalse().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): |
| 2 | 2 | ||||
| 3 | 3 | ||||
| n | 4 | class Mixin: | n | 4 | class Mixin: |
| 5 | counter = 0 | ||||
| 6 | |||||
| 7 | def is_a_witch(self): | 5 | def is_a_witch(self): | ||
| 8 | try: | 6 | try: | ||
| 9 | self.__getattribute__(mass_attr_name) == mass | 7 | self.__getattribute__(mass_attr_name) == mass | ||
| n | n | 8 | return 'Burn her!' | ||
| 10 | except AttributeError: | 9 | except AttributeError: | ||
| 11 | self.counter +=1 | ||||
| 12 | 10 | pass | |||
| 13 | try: | 11 | try: | ||
| 14 | self.__getattribute__(material_attr_name) == material | 12 | self.__getattribute__(material_attr_name) == material | ||
| n | n | 13 | return 'Burn her!' | ||
| 15 | except AttributeError: | 14 | except AttributeError: | ||
| 16 | self.counter +=1 | ||||
| 17 | 15 | pass | |||
| 18 | try: | 16 | try: | ||
| 19 | self.__getattribute__(float_method_name) | 17 | self.__getattribute__(float_method_name) | ||
| n | n | 18 | return 'Burn her!' | ||
| 20 | except AttributeError: | 19 | except AttributeError: | ||
| n | 21 | self.counter += 1 | n | 20 | pass |
| 21 | |||||
| 22 | return 'No, but it\'s a pity, cuz she looks like a witch!' | ||||
| 23 | |||||
| 24 | |||||
| 25 | return Mixin | ||||
| 22 | 26 | ||||
| t | 23 | if self.counter == 3: | t | 27 | |
| 24 | return 'No, but it\'s a pity, cuz she looks like a witch!' | ||||
| 25 | |||||
| 26 | return 'Burn her!' | ||||
| 27 | |||||
| 28 | |||||
| 29 | return Mixin |
| Legends | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
| |||||||||
10.11.2023 10:38
10.11.2023 09:10