On Fri, Nov 12, 2021, 1:39 AM Christopher Barker <pythonchb@gmail.com> wrote:
unittest is the first (and only) testing framework I have ever used, so
any info is appreciated.
Yes, I like Pytest a lot more.
I should really write this up someday, and I did write a bit about it on this list not too long ago.
So the really short version is:
Unittest requires a fair bit of boilerplate that adds no real functionality.
The assert* methods are only there to provide error reporting that can be done by introspection by the test runner (e.g. pytest)
It’s missing some really key features like paramatrized tests.
Give Pytest a try — I suspect you’ll like it.
Note that a LOT of major projects dumped unittest years ago— first for nose and now usually pytest. No one uses a third party library for no reason :-)
-CHB
In my humble opinion, the only two valid reasons to use unittest are if you are writing tests for Python itself, or if you are operating in a locked down enterprise environment where PyPI is off-limits and you have to rely on the stdlib. All other cases should use pytest or something similar (or in a security-conscious environment, petition the appropriate people to evaluate and approve pytest).