My first thought was: it would be very nice, when doing quick and dirty scratch code, to not have to resort to a full fledged test framework to get readable assertions. You could just throw an assert statement in a if __name__ == '__main__' block at the bottom, click the run arrow next to it in pycharm or other IDE, and get more readable assertion errors.
It doesn't seem like it is recreating pytest; pytest is far more than rewritten assertions (though it's a key feature of course). On the other hand, providing an API for hooking into the assert mechanism could be more useful. Imagine pytest spinning out their assertion rewriting functionality into a separate project that you could turn into a plugin in VS Code or Pycharm. And it would be much more easily extendable. +1 on the basic idea/desire for rewritten assertions appearing in more places than pytest. +1 on official support for hooking into the assertion machinery and letting a thousand flowers bloom. +0 on the actual proposed PEP. On Sat, Sep 25, 2021, 5:50 AM Paul Moore <p.f.mo...@gmail.com> wrote: > On Sat, 25 Sept 2021 at 06:09, Stephen J. Turnbull > <stephenjturnb...@gmail.com> wrote: > > > > Guido van Rossum writes: > > > > > I think this is by far the best option. Pytest can evolve much faster > than > > > the stdlib. > > > > Is there no room for making it easier to do this with less invasive > > changes to the stdlib, or are Steven d'A's "heroic measures in an > > import hook" the right way to go? > > +1 on this. There are a number of "better exceptions" packages out > there (for example, `better_exceptions` :-)) which would benefit from > an improved mechanism to introspect failed assertions. A language > change to make life easier for all those packages seems like an > "obvious" feature to me.From there, it's a relatively small step to > having a better *default* assertion reporting mechanism, but the PEP > should focus on the machinery first, and the front end second IMO. > > Paul > _______________________________________________ > Python-ideas mailing list -- python-ideas@python.org > To unsubscribe send an email to python-ideas-le...@python.org > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/python-ideas@python.org/message/J3SQIJ4USRQ3XSUVOSUR5C6NKA3GLQZ4/ > Code of Conduct: http://python.org/psf/codeofconduct/ >
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/EKJ6U3KDDSVURLX4ZPT4XN5TOL2JFHDI/ Code of Conduct: http://python.org/psf/codeofconduct/