<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body><div>Hi John,<br></div>
<div><br></div>
<div>This is interesting and thanks for sharing it. Running python 3.5.2, I firstly simplified your example and got a slightly different exception:<br></div>
<div><br></div>
<div><span class="font" style="font-family:menlo,consolas,monospace,sans-serif">from unittest import mock</span><br></div>
<div><span class="font" style="font-family:menlo,consolas,monospace,sans-serif"></span><br></div>
<div><span class="font" style="font-family:menlo,consolas,monospace,sans-serif"></span><br></div>
<div><span class="font" style="font-family:menlo,consolas,monospace,sans-serif">def test_calls_match():</span><br></div>
<div><span class="font" style="font-family:menlo,consolas,monospace,sans-serif"> """</span><br></div>
<div><span class="font" style="font-family:menlo,consolas,monospace,sans-serif"> Calls on a Mock match expectation</span><br></div>
<div><span class="font" style="font-family:menlo,consolas,monospace,sans-serif"> """</span><br></div>
<div><span class="font" style="font-family:menlo,consolas,monospace,sans-serif"> m = mock.Mock()</span><br></div>
<div><span class="font" style="font-family:menlo,consolas,monospace,sans-serif"> m()</span><br></div>
<div><span class="font" style="font-family:menlo,consolas,monospace,sans-serif"> m.my_method(123)</span><br></div>
<div><span class="font" style="font-family:menlo,consolas,monospace,sans-serif"></span><br></div>
<div><span class="font" style="font-family:menlo,consolas,monospace,sans-serif"> m.assert_has_calls([mock.call(), mock.call().my_method(123)])</span><br></div>
<div><br></div>
<div>The exception is slightly different for me:<br></div>
<div><br></div>
<div><span class="font" style="font-family: menlo, consolas, monospace, sans-serif;">E AssertionError: Calls not found.</span><span class="font" style="font-family: menlo, consolas, monospace, sans-serif;"><br></span></div>
<div><span class="font" style="font-family: menlo, consolas, monospace, sans-serif;">E Expected: [call(), call().my_method(123)]</span><span class="font" style="font-family: menlo, consolas, monospace, sans-serif;"><br></span></div>
<div><span class="font" style="font-family: menlo, consolas, monospace, sans-serif;">E Actual: [call(), call.my_method(123)]</span><span class="font" style="font-family: menlo, consolas, monospace, sans-serif;"><br></span></div>
<div><br></div>
<div>When I remove the parentheses after the second `call`, then everything works for me, and the test passes.<br></div>
<div><br></div>
<div><span class="font" style="font-family: menlo, consolas, monospace, sans-serif;"> m.assert_has_calls([mock.call(), mock.call.my_method(123)])</span><br></div>
<div><br></div>
<div>My assumption is that MagicMock will operate like Mock and that your MockFoo is a MagicMock, so could you try the `mock.call.my_method` on Python 3.4?<br></div>
<div><br></div>
<div>I'm interested to hear how that works for you.<br></div>
<div><br></div>
<div>Cheers,<br></div>
<div><br></div>
<div>James<br></div>
<div><br></div>
<div><br></div>
<div><br></div>
<div><br></div>
<div>On Thu, 16 Feb 2017, at 07:06 PM, John W wrote:<br></div>
<div>> They seem to be the same types.<br></div>
<div>><br></div>
<div>> I added these prints:<br></div>
<div>><br></div>
<div>> print("type of call():", type(call()))<br></div>
<div>> print("type of call().my_method(123):",<br></div>
<div>> type(call().my_method(123)))<br></div>
<div>> for c in MockFoo.mock_calls:<br></div>
<div>> print("type of mock call '{}': {}".format(c, type(c)))<br></div>
<div>><br></div>
<div>> And output is:<br></div>
<div>><br></div>
<div>> type of call(): <class 'unittest.mock._Call'><br></div>
<div>> type of call().my_method(123): <class 'unittest.mock._Call'><br></div>
<div>> type of mock call 'call()': <class 'unittest.mock._Call'><br></div>
<div>> type of mock call 'call().my_method(123)': <class<br></div>
<div>> 'unittest.mock._Call'><br></div>
<div>><br></div>
<div>><br></div>
<div>> Thanks for the suggestion though.<br></div>
<div>> I've been getting crickets from every place I've asked this question (:<br></div>
<div>><br></div>
<div>> -John<br></div>
<div>><br></div>
<div>> _______________________________________________<br></div>
<div>> testing-in-python mailing list<br></div>
<div>> testing-in-python@lists.idyll.org<br></div>
<div>> http://lists.idyll.org/listinfo/testing-in-python<br></div>
<div><br></div>
<div><br></div>
<div>--<br></div>
<div>James Cooke<br></div>
<div>Backend software developer<br></div>
<div>CV PDF: http://jamescooke.info/docs/james_cooke_cv.pdf<br></div>
<div>Website: http://jamescooke.info/<br></div>
</body>
</html>