New submission from Randy Syring:

In issue http://bugs.python.org/issue21238 a feature was introduced to help 
prevent false-positive test cases by throwing an AttributeError whenever a 
non-existent method prefixed with "assert_" is used on a mock object.

I had mock objects with legitimate "assert_*" methods that had been working for 
some time.  My tests included calls like:

my_mock.assert_in_status.assert_called_once_with(...)

My tests started failing unexpectedly and it took me HOURS to figure out that I 
had a new mock version installed.  Those hours could have been turned into 
seconds my simply giving a better error message, something like:

AttributeError: you used "assert_in_status" but that method is not a valid Mock 
assert method.  Please check your spelling.  If this was not a typing mistake, 
you can use the `unsafe` keyword argument to the Mock instance to turn this 
validation check off.  See https://mock-docs...org/ for more details.

----------
components: Library (Lib)
messages: 247690
nosy: Randy Syring
priority: normal
severity: normal
status: open
title: unittest.mock.Mock's new "unsafe" feature needs a better error message
type: behavior
versions: Python 3.5

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue24758>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to