Visitar URL original
bpo-29403: Fix mock's broken autospec behavior on method-bound builtin functions by habnabit · Pull Request #3 · python/cpython · GitHub
Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Move test to correct test case
  • Loading branch information
berkerpeksag committed Jul 19, 2017
commit 4f4ed0209b42706737c01f84aa435c702f7884af
26 changes: 13 additions & 13 deletions Lib/unittest/test/testmock/testhelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,19 @@ def check_data_descriptor(mock_attr):
check_data_descriptor(foo.desc)


def test_autospec_on_bound_builtin_function(self):
meth = types.MethodType(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):

def test_args_list_contains_call_list(self):
Expand Down Expand Up @@ -885,19 +898,6 @@ def test_args_list_contains_call_list(self):
self.assertNotIn([call('fish')], mock.call_args_list)


def test_autospec_on_bound_builtin_function(self):
meth = types.MethodType(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)


def test_call_list_str(self):
mock = Mock()
mock(1, 2)
Expand Down