[issue24651] Mock.assert* API is in user namespace

Erik Bray report at bugs.python.org
Tue Jul 28 20:20:38 CEST 2015


Erik Bray added the comment:

Would it be possible to add the functions and *not* deprecate assert_ methods?

The existing solution is still acknowledged to be an incomplete solution.  It is still possible to make other typos that result in unintentional non-assertions (it's also not entirely clear from the docs when one would want to set unsafe=True, though at least the default unsafe=False is better).  I'm not against the existing solution--I think it's reasonable and that calls of "special cases yadda yadda" are unfair. Sometimes practicality beats purity.

So, although adding assert_ functions would be a bit redundant, it's also guaranteed safer, and so probably worth making an exception for.  

There's a tradeoff here between convenience and robustness and I think we can have it both ways.  If I were to write new tests using Mock I would probably define such functions myself, but that would get repetitive quickly.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24651>
_______________________________________


More information about the Python-bugs-list mailing list