3 ms·
pytest is great, but a just a bit too much magic for me. And I really don't like it when you pass a user defined failure message, you lose all this nice intros
by jgalt212 9y ago
pytest is great, but a just a bit too much magic for me. And I really don't like it when you pass a user defined failure message, you lose all this nice introspection.
With unittest, longMessage = True + my own failure message with the info I want gets me where I need to be. That being said, it is more work/boilerplate.
https://docs.python.org/2/library/unittest.html#unittest.TestCase.longMessage https://docs.python.org/2/library/unittest.html#unittest.Tes...
Python 3 has subtest, which gives you built in parameterized testing. I have no idea why this was not backported to 2.7, so you must used pytest or nose_parameterized or ddt.
https://docs.python.org/3/library/unittest.html#unittest.TestCase.subTest https://docs.python.org/3/library/unittest.html#unittest.Tes...
- masklinn 9y ago> pytest is great, but a just a bit too much magic for me. There isn't much magic there, just an import hook which rewrites the assertion during compilation. > And I really don't like it when you pass a user defined failure message, you lose all this nice introspection. Er… you don't, that's what the second snippet shows: if you have a custom assertion message, it just prints the message alongside everything else…
- jgalt212 9y ago> Er… you don't, that's what the second snippet shows: if you have a custom assertion message, it just prints the message alongside everything else… Is that a new addition to pytest? I do seem to remember the user defined message stomping over whatever pytest would normally spit out.
- masklinn 9y agoThat seems to have been fixed in version 2.6.2 released in September 2014[0]: > Implement issue549: user-provided assertion messages now no longer replace the py.test introspection message but are shown in addition to them. [0] https://docs.pytest.org/en/latest/changelog.html#id228 https://docs.pytest.org/en/latest/changelog.html#id228
- jgalt212 9y agocool, thanks for clearing that up for me.