What is the best alternative to unittest?
Here’s the Deal
Slant is powered by a community that helps you make informed decisions. Tell us what you’re passionate about to get your personalized feed and help others.
The idioms that pytest first introduced brought a change in the Python community because they made it possible for test suites to be written in a very compact style, or at least far more compact than was ever possible before. Pytest basically introduced the concept that Python tests should be plain Python functions instead of forcing developers to include their tests inside large test classes. See More
The fact that pytest uses it's own special routines to write tests means that you are trading convenience for compatibility. In other words, writing tests for pytest means that you are tying yourself to only pytest and the only way to use another testing framework is to rewrite most of the code. See More
With most other tools you have to use debugger or extra logging to find out where did some value came from in your test. Not with pytest! Pytest rewrites your test so that it can store all intermediate values that can lead to failing assert and provides you with very pretty explanation about what has been asserted and what have failed. See More
Pytest can easily be extended with several hooks, and the same team develops a number of very useful plugins. For example, you install pytest-xdist, and parallel test execution just works, with all the same benefits you had with pytest (as opposed to having to use a separate test runner, for example) See More
A fixture is just a function that returns a value and to use a fixture you just have to add an argument to your test function. You can also use a fixture from another fixture in the same manner, so it's easy to make them modular. You can also parametrize fixture and every test that uses it will run with all values of parameters, no test rewrite needed. If your test uses several fixtures, all parameters' combinations will be covered. See More
Help millions of people make better decisions.
Each month, over 1.7 million people use Slant to find the best products and share their knowledge. Pick the tags you’re passionate about to get a personalized feed and begin contributing your knowledge.