Предизвикателства > She's a witch! > Решения > Решението на Момчил Узунов

Резултати
0 точки от тестове
0 точки от учител

0 точки общо

0 успешни теста
1 неуспешни теста
Код (noted)
Скрий всички коментари

 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)

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

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):
2    2    
3    3    
n4    class Mixin:            n4    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) == mass7                self.__getattribute__(mass_attr_name) == mass
nn8                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) == material12                self.__getattribute__(material_attr_name) == material
nn13                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)
nn18                return 'Burn her!'
20            except AttributeError:19            except AttributeError:
n21                self.counter += 1n20                pass              
21                     
22            return 'No, but it\'s a pity, cuz she looks like a witch!'
23            
24            
25    return Mixin
2226
t23            if self.counter == 3:t27    
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
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op