File tree Expand file tree Collapse file tree
Lib/unittest/test/testmock Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88)
99
1010from datetime import datetime
11+ from functools import partial
1112
1213class SomeClass (object ):
1314 def one (self , a , b ):
@@ -871,6 +872,19 @@ def test_autospec_on_bound_builtin_function(self):
871872 mocked .assert_called_once_with (4 , 5 , 6 )
872873
873874
875+ def test_autospec_getattr_partial_function (self ):
876+ # bpo-32153 : getattr returning partial functions without
877+ # __name__ should not create AttributeError in create_autospec
878+ class Foo :
879+
880+ def __getattr__ (self , attribute ):
881+ return partial (lambda name : name , attribute )
882+
883+ proxy = Foo ()
884+ autospec = create_autospec (proxy )
885+ self .assertFalse (hasattr (autospec , '__name__' ))
886+
887+
874888class TestCallList (unittest .TestCase ):
875889
876890 def test_args_list_contains_call_list (self ):
You can’t perform that action at this time.
0 commit comments