[issue36871] Misleading error from unittest.mock's assert_has_calls

Gregory P. Smith report at bugs.python.org
Thu May 9 21:20:28 EDT 2019


New submission from Gregory P. Smith <greg at krypto.org>:

Thing: <class '__main__.Thing'>
mock_thing.method sig=(a=None, b=0)
F
======================================================================
FAIL: test_has_calls_on_thing (__main__.MockCallTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/google/home/gps/mock_call_test.py", line 25, in test_has_calls_on_thing
    mock_thing.assert_has_calls([
  File "/usr/local/google/home/gps/oss/cpython/gpshead/Lib/unittest/mock.py", line 843, in assert_has_calls
    raise AssertionError(
AssertionError: Calls not found.
Expected: [call.method(0.5, b=3000), call.method(0.6, b=6000), call.method(0.7, b=9000)]
Actual: [call.method(0.5, b=3000), call.method(0.6, b=6000), call.method(0.7, b=9000)].

See the attached mock_call_test.py.

----------
components: Library (Lib)
files: mock_call_test.py
messages: 342028
nosy: gregory.p.smith
priority: normal
severity: normal
stage: needs patch
status: open
title: Misleading error from unittest.mock's assert_has_calls
type: behavior
versions: Python 3.6, Python 3.7, Python 3.8
Added file: https://bugs.python.org/file48323/mock_call_test.py

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36871>
_______________________________________


More information about the Python-bugs-list mailing list