@@ -14,15 +14,15 @@ def my_global_function(a, b):
1414
1515class AboutMethods (Koan ):
1616 def test_calling_a_global_function (self ):
17- self .assertEqual (__ , my_global_function (2 , 3 ))
17+ self .assertEqual (5 , my_global_function (2 , 3 ))
1818
1919 # NOTE: Wrong number of arguments is not a SYNTAX error, but a
2020 # runtime error.
2121 def test_calling_functions_with_wrong_number_of_arguments (self ):
2222 try :
2323 my_global_function ()
2424 except Exception as exception :
25- self .assertEqual (__ , type (exception ).__name__ )
25+ self .assertEqual ('TypeError' , type (exception ).__name__ )
2626 self .assertMatch (
2727 r'my_global_function\(\) takes exactly 2 arguments \(0 given\)' ,
2828 exception [0 ])
@@ -32,15 +32,15 @@ def test_calling_functions_with_wrong_number_of_arguments(self):
3232 except Exception as e :
3333
3434 # Note, watch out for parenthesis. They need slashes in front!
35- self .assertMatch (__ , e [0 ])
35+ self .assertMatch (r'my_global_function\(\) takes exactly 2 arguments \(3 given\)' , e [0 ])
3636
3737 # ------------------------------------------------------------------
3838
3939 def pointless_method (self , a , b ):
4040 sum = a + b
4141
4242 def test_which_does_not_return_anything (self ):
43- self .assertEqual (__ , self .pointless_method (1 , 2 ))
43+ self .assertEqual (None , self .pointless_method (1 , 2 ))
4444 # Notice that methods accessed from class scope do not require
4545 # you to pass the first "self" argument?
4646
@@ -50,18 +50,18 @@ def method_with_defaults(self, a, b='default_value'):
5050 return [a , b ]
5151
5252 def test_calling_with_default_values (self ):
53- self .assertEqual (__ , self .method_with_defaults (1 ))
54- self .assertEqual (__ , self .method_with_defaults (1 , 2 ))
53+ self .assertEqual ([ 1 , 'default_value' ] , self .method_with_defaults (1 ))
54+ self .assertEqual ([ 1 , 2 ] , self .method_with_defaults (1 , 2 ))
5555
5656 # ------------------------------------------------------------------
5757
5858 def method_with_var_args (self , * args ):
5959 return args
6060
6161 def test_calling_with_variable_arguments (self ):
62- self .assertEqual (__ , self .method_with_var_args ())
62+ self .assertEqual (() , self .method_with_var_args ())
6363 self .assertEqual (('one' , ), self .method_with_var_args ('one' ))
64- self .assertEqual (__ , self .method_with_var_args ('one' , 'two' ))
64+ self .assertEqual (( 'one' , 'two' ) , self .method_with_var_args ('one' , 'two' ))
6565
6666 # ------------------------------------------------------------------
6767
@@ -72,13 +72,13 @@ def test_functions_without_self_arg_are_global_functions(self):
7272 def function_with_the_same_name (a , b ):
7373 return a * b
7474
75- self .assertEqual (__ , function_with_the_same_name (3 , 4 ))
75+ self .assertEqual (12 , function_with_the_same_name (3 , 4 ))
7676
7777 def test_calling_methods_in_same_class_with_explicit_receiver (self ):
7878 def function_with_the_same_name (a , b ):
7979 return a * b
8080
81- self .assertEqual (__ , self .function_with_the_same_name (3 , 4 ))
81+ self .assertEqual (7 , self .function_with_the_same_name (3 , 4 ))
8282
8383 # ------------------------------------------------------------------
8484
@@ -91,32 +91,32 @@ def another_method_with_the_same_name(self):
9191 return 42
9292
9393 def test_that_old_methods_are_hidden_by_redefinitions (self ):
94- self .assertEqual (__ , self .another_method_with_the_same_name ())
94+ self .assertEqual (42 , self .another_method_with_the_same_name ())
9595
9696 def test_that_overlapped_method_is_still_there (self ):
97- self .assertEqual (__ , self .link_to_overlapped_method ())
97+ self .assertEqual (10 , self .link_to_overlapped_method ())
9898
9999 # ------------------------------------------------------------------
100100
101101 def empty_method (self ):
102102 pass
103103
104104 def test_methods_that_do_nothing_need_to_use_pass_as_a_filler (self ):
105- self .assertEqual (__ , self .empty_method ())
105+ self .assertEqual (None , self .empty_method ())
106106
107107 def test_pass_does_nothing_at_all (self ):
108108 "You"
109109 "shall"
110110 "not"
111111 pass
112- self .assertEqual (____ , "Still got to this line" != None )
112+ self .assertEqual (True , "Still got to this line" != None )
113113
114114 # ------------------------------------------------------------------
115115
116116 def one_line_method (self ): return 'Madagascar'
117117
118118 def test_no_indentation_required_for_one_line_statement_bodies (self ):
119- self .assertEqual (__ , self .one_line_method ())
119+ self .assertEqual ('Madagascar' , self .one_line_method ())
120120
121121 # ------------------------------------------------------------------
122122
@@ -125,7 +125,7 @@ def method_with_documentation(self):
125125 return "ok"
126126
127127 def test_the_documentation_can_be_viewed_with_the_doc_method (self ):
128- self .assertMatch (__ , self .method_with_documentation .__doc__ )
128+ self .assertMatch ("A string placed at the beginning of a function is used for documentation" , self .method_with_documentation .__doc__ )
129129
130130 # ------------------------------------------------------------------
131131
@@ -142,13 +142,13 @@ def __password(self):
142142
143143 def test_calling_methods_in_other_objects (self ):
144144 rover = self .Dog ()
145- self .assertEqual (__ , rover .name ())
145+ self .assertEqual ("Fido" , rover .name ())
146146
147147 def test_private_access_is_implied_but_not_enforced (self ):
148148 rover = self .Dog ()
149149
150150 # This is a little rude, but legal
151- self .assertEqual (__ , rover ._tail ())
151+ self .assertEqual ("wagging" , rover ._tail ())
152152
153153 def test_double_underscore_attribute_prefixes_cause_name_mangling (self ):
154154 """Attributes names that start with a double underscore get
@@ -158,10 +158,10 @@ def test_double_underscore_attribute_prefixes_cause_name_mangling(self):
158158 #This may not be possible...
159159 password = rover .__password ()
160160 except Exception as ex :
161- self .assertEqual (__ , type (ex ).__name__ )
161+ self .assertEqual ('AttributeError' , type (ex ).__name__ )
162162
163163 # But this still is!
164- self .assertEqual (__ , rover ._Dog__password ())
164+ self .assertEqual ('password' , rover ._Dog__password ())
165165
166166 # Name mangling exists to avoid name clash issues when subclassing.
167167 # It is not for providing effective access protection
0 commit comments