[New-bugs-announce] [issue31541] Mock called_with does not ensure self/cls argument is used
JonathanHuot
report at bugs.python.org
Thu Sep 21 05:35:48 EDT 2017
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 <report at bugs.python.org>
<https://bugs.python.org/issue31541>
_______________________________________
More information about the New-bugs-announce
mailing list