<!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">&nbsp;&nbsp;&nbsp; """</span><br></div>
<div><span class="font" style="font-family:menlo,consolas,monospace,sans-serif">&nbsp;&nbsp;&nbsp; Calls on a Mock match expectation</span><br></div>
<div><span class="font" style="font-family:menlo,consolas,monospace,sans-serif">&nbsp;&nbsp;&nbsp; """</span><br></div>
<div><span class="font" style="font-family:menlo,consolas,monospace,sans-serif">&nbsp;&nbsp;&nbsp; m = mock.Mock()</span><br></div>
<div><span class="font" style="font-family:menlo,consolas,monospace,sans-serif">&nbsp;&nbsp;&nbsp; m()</span><br></div>
<div><span class="font" style="font-family:menlo,consolas,monospace,sans-serif">&nbsp;&nbsp;&nbsp; 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">&nbsp;&nbsp;&nbsp; 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&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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;">&nbsp;&nbsp;&nbsp; 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>&gt; They seem to be the same types.<br></div>
<div>&gt;<br></div>
<div>&gt; I added these prints:<br></div>
<div>&gt;<br></div>
<div>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print("type of call():", type(call()))<br></div>
<div>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print("type of call().my_method(123):",<br></div>
<div>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; type(call().my_method(123)))<br></div>
<div>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for c in MockFoo.mock_calls:<br></div>
<div>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print("type of mock call '{}': {}".format(c, type(c)))<br></div>
<div>&gt;<br></div>
<div>&gt; And output is:<br></div>
<div>&gt;<br></div>
<div>&gt;&nbsp;&nbsp;&nbsp;&nbsp; type of call(): &lt;class 'unittest.mock._Call'&gt;<br></div>
<div>&gt;&nbsp;&nbsp;&nbsp;&nbsp; type of call().my_method(123): &lt;class 'unittest.mock._Call'&gt;<br></div>
<div>&gt;&nbsp;&nbsp;&nbsp;&nbsp; type of mock call 'call()': &lt;class 'unittest.mock._Call'&gt;<br></div>
<div>&gt;&nbsp;&nbsp;&nbsp;&nbsp; type of mock call 'call().my_method(123)': &lt;class<br></div>
<div>&gt;&nbsp;&nbsp;&nbsp;&nbsp; 'unittest.mock._Call'&gt;<br></div>
<div>&gt;<br></div>
<div>&gt;<br></div>
<div>&gt; Thanks for the suggestion though.<br></div>
<div>&gt; I've been getting crickets from every place I've asked this question (:<br></div>
<div>&gt;<br></div>
<div>&gt; -John<br></div>
<div>&gt;<br></div>
<div>&gt; _______________________________________________<br></div>
<div>&gt; testing-in-python mailing list<br></div>
<div>&gt; testing-in-python@lists.idyll.org<br></div>
<div>&gt; 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>