New submission from JonathanHuot:
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
----------
components: Library (Lib)
messages: 302677
nosy: jonathan.huot
priority: normal
severity: normal
status: open
title: Mock called_with does not ensure self/cls argument is used
type: behavior
versions: Python 3.3, Python 3.4, Python 3.5, Python 3.6, Python 3.7
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue31541>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com