Skip to content
Prev Previous commit
Next Next commit
Use a function which is defined without a signature
Any builtin function can get a signature, therefore the test uses the
function which exists for testing the lack of it.
  • Loading branch information
serhiy-storchaka committed Aug 13, 2026
commit ca3e77105aa9b1da1f988a87a1ec42d8d55edfeb
9 changes: 6 additions & 3 deletions Lib/test/test_unittest/testmock/testhelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import types
import unittest

from test.support import import_helper

from unittest.mock import (
call, _Call, create_autospec, MagicMock,
Mock, ANY, _CallList, patch, PropertyMock, _callable
Expand Down Expand Up @@ -928,9 +930,10 @@ def check_data_descriptor(mock_attr):


def test_autospec_on_bound_builtin_function(self):
# max() is variadic, therefore it has no signature.
meth = types.MethodType(max, [4, 5, 6])
self.assertEqual(meth(), 6)
_testcapi = import_helper.import_module('_testcapi')
# This function is defined without a signature.
meth = types.MethodType(_testcapi.docstring_no_signature, object())
self.assertIsNone(meth())
mocked = create_autospec(meth)

# no signature, so no spec to check against
Expand Down
Loading