AttributeError: tests and solutions
what causes AttributeError?: tests and solutions
what causes AttributeError? tests
The code in attribute_error/tests/test_attribute_error.py from what causes AttributeError?
1import src.attribute_error
2
3
4def test_attribute_error_w_variables():
5 src.attribute_error.variable_00
6 src.attribute_error.variable_01
7 src.attribute_error.variable_02
8 src.attribute_error.variable_03
9 src.attribute_error.variable_04
10 src.attribute_error.variable_05
11 src.attribute_error.variable_06
12 src.attribute_error.variable_07
13 src.attribute_error.variable_08
14 src.attribute_error.variable_09
15
16
17def test_attribute_error_w_functions():
18 src.attribute_error.function_00()
19 src.attribute_error.function_01()
20 src.attribute_error.function_02()
21 src.attribute_error.function_03()
22 src.attribute_error.function_04()
23 src.attribute_error.function_05()
24 src.attribute_error.function_06()
25 src.attribute_error.function_07()
26 src.attribute_error.function_08()
27 src.attribute_error.function_09()
28
29
30# Exceptions seen
31# AssertionError
32# ModuleNotFoundError
33# AttributeError
34# NameError
35# TypeError
what causes AttributeError? solutions
the solutions in attribute_error/src/attribute_error.py from what causes AttributeError?
1variable_00 = None
2variable_01 = variable_00
3variable_02 = variable_01
4variable_03 = variable_02
5variable_04 = variable_03
6variable_05 = variable_04
7variable_06 = variable_05
8variable_07 = variable_06
9variable_08 = variable_07
10variable_09 = variable_08
11
12
13def function_00(): return variable_09
14def function_01(): return function_00()
15def function_02(): return function_01()
16def function_03(): return function_02()
17def function_04(): return function_03()
18def function_05(): return function_04()
19def function_06(): return function_05()
20def function_07(): return function_06()
21def function_08(): return function_07()
22def function_09(): return function_08()
23
24
25class AClass(object):
26
27 attribute_00 = function_09()
28 attribute_01 = attribute_00
29 attribute_02 = attribute_01
30 attribute_03 = attribute_02
31 attribute_04 = attribute_03
32 attribute_05 = attribute_04
33 attribute_06 = attribute_05
34 attribute_07 = attribute_06
35 attribute_08 = attribute_07
36 attribute_09 = attribute_08
37
38 def method_00(self): return self.attribute_09
39 def method_01(self): return self.method_00()
40 def method_02(self): return self.method_01()
41 def method_03(self): return self.method_02()
42 def method_04(self): return self.method_03()
43 def method_05(self): return self.method_04()
44 def method_06(self): return self.method_05()
45 def method_07(self): return self.method_06()
46 def method_08(self): return self.method_07()
47 def method_09(self): return self.method_08()
AttributeError with classes: tests and solutions
AttributeError with classes tests
The code in attribute_error/tests/test_attribute_error_w_classes.py from AttributeError with classes
1import src.attribute_error
2
3
4def test_attribute_error_w_variables():
5 src.attribute_error.variable_00
6 src.attribute_error.variable_01
7 src.attribute_error.variable_02
8 src.attribute_error.variable_03
9 src.attribute_error.variable_04
10 src.attribute_error.variable_05
11 src.attribute_error.variable_06
12 src.attribute_error.variable_07
13 src.attribute_error.variable_08
14 src.attribute_error.variable_09
15
16
17def test_attribute_error_w_functions():
18 src.attribute_error.function_00()
19 src.attribute_error.function_01()
20 src.attribute_error.function_02()
21 src.attribute_error.function_03()
22 src.attribute_error.function_04()
23 src.attribute_error.function_05()
24 src.attribute_error.function_06()
25 src.attribute_error.function_07()
26 src.attribute_error.function_08()
27 src.attribute_error.function_09()
28
29
30def test_attribute_error_w_class_attributes():
31 src.attribute_error.AClass.attribute_00
32 src.attribute_error.AClass().attribute_01
33 src.attribute_error.AClass.attribute_02
34 src.attribute_error.AClass().attribute_03
35 src.attribute_error.AClass.attribute_04
36 src.attribute_error.AClass().attribute_05
37 src.attribute_error.AClass().attribute_06
38 src.attribute_error.AClass.attribute_07
39 src.attribute_error.AClass.attribute_08
40 src.attribute_error.AClass().attribute_09
41
42
43def test_attribute_error_w_class_methods():
44 src.attribute_error.AClass().method_00()
45 src.attribute_error.AClass().method_01()
46 src.attribute_error.AClass().method_02()
47 src.attribute_error.AClass().method_03()
48 src.attribute_error.AClass().method_04()
49 src.attribute_error.AClass().method_05()
50 src.attribute_error.AClass().method_06()
51 src.attribute_error.AClass().method_07()
52 src.attribute_error.AClass().method_08()
53 src.attribute_error.AClass().method_09()
54
55
56# Exceptions seen
57# AssertionError
58# ModuleNotFoundError
59# AttributeError
60# NameError
61# TypeError
62# SyntaxError
AttributeError with classes solutions
the solutions in attribute_error/solutions/attribute_error.py from AttributeError with classes
1variable_00 = None
2variable_01 = variable_00
3variable_02 = variable_01
4variable_03 = variable_02
5variable_04 = variable_03
6variable_05 = variable_04
7variable_06 = variable_05
8variable_07 = variable_06
9variable_08 = variable_07
10variable_09 = variable_08
11
12
13def function_00(): return variable_09
14def function_01(): return function_00()
15def function_02(): return function_01()
16def function_03(): return function_02()
17def function_04(): return function_03()
18def function_05(): return function_04()
19def function_06(): return function_05()
20def function_07(): return function_06()
21def function_08(): return function_07()
22def function_09(): return function_08()
23
24
25class AClass(object):
26
27 attribute_00 = function_09()
28 attribute_01 = attribute_00
29 attribute_02 = attribute_01
30 attribute_03 = attribute_02
31 attribute_04 = attribute_03
32 attribute_05 = attribute_04
33 attribute_06 = attribute_05
34 attribute_07 = attribute_06
35 attribute_08 = attribute_07
36 attribute_09 = attribute_08
37
38 def method_00(self): return self.attribute_09
39 def method_01(self): return self.method_00()
40 def method_02(self): return self.method_01()
41 def method_03(self): return self.method_02()
42 def method_04(self): return self.method_03()
43 def method_05(self): return self.method_04()
44 def method_06(self): return self.method_05()
45 def method_07(self): return self.method_06()
46 def method_08(self): return self.method_07()
47 def method_09(self): return self.method_08()