Merge pull request #389 from habnabit/fix-builtin-methods-for-cython

Fix autospec's behavior on method-bound builtin functions
diff --git a/mock/mock.py b/mock/mock.py
index 8e05f49..7f7625f 100644
--- a/mock/mock.py
+++ b/mock/mock.py
@@ -280,7 +280,7 @@
     skipfirst = isinstance(original, ClassTypes)
     result = _get_signature_object(original, instance, skipfirst)
     if result is None:
-        return
+        return mock
     func, sig = result
     def checksig(*args, **kwargs):
         sig.bind(*args, **kwargs)
diff --git a/mock/tests/testhelpers.py b/mock/tests/testhelpers.py
index eb38b21..2bfe2c8 100644
--- a/mock/tests/testhelpers.py
+++ b/mock/tests/testhelpers.py
@@ -3,6 +3,7 @@
 # http://www.voidspace.org.uk/python/mock/
 
 import six
+import time
 import unittest
 
 from mock import (
@@ -885,6 +886,18 @@
         mock_slot.assert_called_once_with(1, 2, 3)
         mock_slot.abc.assert_called_once_with(4, 5, 6)
 
+    def test_autospec_on_bound_builtin_function(self):
+        meth = six.create_bound_method(time.ctime, time.time())
+        self.assertIsInstance(meth(), str)
+        mocked = create_autospec(meth)
+
+        # no signature, so no spec to check against
+        mocked()
+        mocked.assert_called_once_with()
+        mocked.reset_mock()
+        mocked(4, 5, 6)
+        mocked.assert_called_once_with(4, 5, 6)
+
 
 class TestCallList(unittest.TestCase):