[issue24758] unittest.mock.Mock's new "unsafe" feature needs a better error message
Randy Syring added the comment: Old functionality: (temp)rsyring@loftex:~/projects/hllapi-src$ python Python 2.7.6 (default, Jun 22 2015, 17:58:13) [GCC 4.8.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import mock >>> mock.__version__ '1.0.0' >>> m = mock.Mock() >>> m.assert_screen_status.call_count 0 New functionality: (temp)rsyring@loftex:~/projects/hllapi-src$ python Python 2.7.6 (default, Jun 22 2015, 17:58:13) [GCC 4.8.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import mock >>> mock.__version__ '1.1.0' >>> m = mock.Mock() >>> m.assert_screen_status.call_count Traceback (most recent call last): File "", line 1, in File "/home/rsyring/.virtualenvs/temp/local/lib/python2.7/site-packages/mock/mock.py", line 714, in __getattr__ raise AttributeError(name) AttributeError: assert_screen_status In my case, the objects I was patching had a legit method like assert_screen_status(). But, after upgrading Mock, the use of those methods started throwing AttributeError's even though it was very obvious that a) the methods existed on the real objects and b) Mock is supposed to let me call anything on I want. As I said previously, this was a VERY confusing situation to figure out. -- ___ Python tracker <http://bugs.python.org/issue24758> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24758] unittest.mock.Mock's new "unsafe" feature needs a better error message
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 <http://bugs.python.org/issue24758> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4809] 2.5.4 release missing from python.org/downloads
New submission from Randy Syring : http://www.python.org/download/ is missing a link to 2.5.4 in the standard releases section. -- assignee: georg.brandl components: Documentation messages: 78832 nosy: georg.brandl, rsyring severity: normal status: open title: 2.5.4 release missing from python.org/downloads ___ Python tracker <http://bugs.python.org/issue4809> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com