Message 287728 - Python tracker

Message287728

Author jwdevel
Recipients jekin000, jwdevel, michael.foord, rbcollins
Date 2017-02-13.21:54:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1487022841.93.0.27570819549.issue26752@psf.upfronthosting.co.za>
In-reply-to
Content
This also seems to apply to unittest.mock in Python3.4.

I described my similar issue on SO: http://stackoverflow.com/questions/42212433/what-is-wrong-with-this-simple-py-test-use-case

It seems like it may be the same issue described here.

For reference, this is my repro case:

from unittest.mock import patch, call

    class Foo:
        def __init__(self):
            pass
        def my_method(self, value):
            pass
    
    def test_foo():
        with patch('test.Foo', autospec=True) as MockFoo:
            m = MockFoo()
            m.my_method(123)
            MockFoo.assert_has_calls([call(), call().my_method(123)])

It fails with:

    ...
    E               AssertionError: Calls not found.
    E               Expected: [call(), call().my_method(123)]
    E               Actual:   [call(), call().my_method(123)]

Which seems nonsensical to me.

Removing the `value` parameter and the `123` arguments in the test makes it pass(!)
History
Date User Action Args
2017-02-13 21:54:02jwdevelsetrecipients: + jwdevel, rbcollins, michael.foord, jekin000
2017-02-13 21:54:01jwdevelsetmessageid: <1487022841.93.0.27570819549.issue26752@psf.upfronthosting.co.za>
2017-02-13 21:54:01jwdevellinkissue26752 messages
2017-02-13 21:54:01jwdevelcreate