summaryrefslogtreecommitdiff
path: root/mock
diff options
context:
space:
mode:
Diffstat (limited to 'mock')
-rw-r--r--mock/tests/testhelpers.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/mock/tests/testhelpers.py b/mock/tests/testhelpers.py
index e7c42f6..cc3e4f8 100644
--- a/mock/tests/testhelpers.py
+++ b/mock/tests/testhelpers.py
@@ -15,6 +15,7 @@ from mock import (
from mock.mock import _Call, _CallList
from datetime import datetime
+from functools import partial
class SomeClass(object):
def one(self, a, b):
@@ -962,6 +963,17 @@ class SpecSignatureTest(unittest.TestCase):
self.assertRaises(TypeError, sock_class, foo=1)
+ def test_autospec_getattr_partial_function(self):
+ # bpo-32153 : getattr returning partial functions without
+ # __name__ should not create AttributeError in create_autospec
+ class Foo:
+ def __getattr__(self, attribute):
+ return partial(lambda name: name, attribute)
+ proxy = Foo()
+ autospec = create_autospec(proxy)
+ self.assertFalse(hasattr(autospec, '__name__'))
+
+
class TestCallList(unittest.TestCase):
def test_args_list_contains_call_list(self):