This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jonathan.huot
Recipients jonathan.huot
Date 2017-09-21.09:35:48
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1505986548.45.0.223796234627.issue31541@psf.upfronthosting.co.za>
In-reply-to
Content
Mock "assert_called_with" does not contain a possibility to verify if "self" or "cls" is used when mock is called.

So, in unittests, all tests are passing but code is broken. Example :


Steps to reproduce:
==================

class Something(object):
    def foobar(self):
        pass

    def foo(self):
        self.foobar()

    def bar(self):
        Something.foobar()  # this is broken


from unittest import mock
x = mock.Mock(spec=Something)
x.foo()
x.foo.assert_called_with()
x.bar()
x.bar.assert_called_with()  # this assertion pass!

# real code 
z = Something()
z.foo()
z.bar()  # raise exception
History
Date User Action Args
2017-09-21 09:35:48jonathan.huotsetrecipients: + jonathan.huot
2017-09-21 09:35:48jonathan.huotsetmessageid: <1505986548.45.0.223796234627.issue31541@psf.upfronthosting.co.za>
2017-09-21 09:35:48jonathan.huotlinkissue31541 messages
2017-09-21 09:35:48jonathan.huotcreate