I am trying to implement a full and clean way of testing python packages, one that would suit the folowing requirements:
I used several approaches: nose + pytest
, tox + pytest
but recently discovered that pytest
should be able to do most of the stuff.
The main problem is that I wasn't able to find a clear comparision regarding when it would be better to use one approach or another.
Can someone explain these and give some use cases or limitations of these configurations? ... just to make it clear when when you go for one approach or another.
In the end I do want to have these options:
quicktest
- run the tests locally, a must before each commmitfulltest
- full tests, running them across all available platforms, a must before making a new releaseWhich is better – pytest or unittest? Although both the frameworks are great for performing testing in python, pytest is easier to work with. The code in pytest is simple, compact, and efficient. For unittest, we will have to import modules, create a class and define the testing functions within that class.
TestCase is used to create test cases by subclassing it. The last block of the code at the bottom allows us to run all the tests just by running the file.
py.test covers all your needs perfectly it's pros comparing to other test runners like nose:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With