I'm looking for a way of running python -m unittest discover
, which will discover tests in, say, directories A, B and C. However, directories A, B and C have directories named dependencies
inside each of them, in which there are also some tests which, however, I don't want to run.
Is there a way to run my tests satisfying these constraints without having to create a script for this?
I've managed to do it this way (In *NIX):
find `pwd` -name '*_test.py' -not -path '*unwanted_path*' \
| xargs python3 -m unittest -v
That is, the tests are discovered by find
, which allows for options like path pattern exclusions, then they're passed to the unittest
command as argument list.
Note that I had to switch to find pwd
, where usually I can write find .
, since relative paths in the form ./xxx
aren't accepted by unittest
(module not found).
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