4 ms·
If you’re using pytest you just paramaterize the tests and it tells you the exact failing case. Seems to be a basic feature I would be surprised to know doesn’t
by profunctor 4y ago
If you’re using pytest you just paramaterize the tests and it tells you the exact failing case. Seems to be a basic feature I would be surprised to know doesn’t exist across almost all commonly used frameworks.
- danuker 4y agoWe are using unittest. But thanks for bringing it up, it seems it also has "subtest" support, which might be easier than interpolating the error message in some cases: https://docs.python.org/3/library/unittest.html#distinguishing-test-iterations-using-subtests https://docs.python.org/3/library/unittest.html#distinguishi...
- Dunedan 4y agoThere is also `parameterized` [1] if you want to do it by using decorators. [1]: https://pypi.org/project/parameterized/ https://pypi.org/project/parameterized/
- masklinn 4y ago> We are using unittest. Unless you need the library style in order to drive it, switch to pytest. Seriously. - assert rewriting is stellar, so much more comfortable than having to find the right assert* method, and tell people they're using the wrong one in reviews - runner is a lot more practical and flexible: nodeids, marks, -k, --lf, --sw, ... - extensions further add flexibility e.g. timeouts, maxfail, xdist (though it has a few drawbacks) - no need for classes (you can have them, mind, but if functions are sufficient, you can use functions) - fixtures > setup/teardown - parameterized tests
- jjgreen 4y agoYou mean "subTest", I switched to pytest just to get away from the camel (and it's in the standard library!)
- ericvsmith 4y agoCame here to mention unittest.subtest. It's for exactly this case.