So the reason this wasn't working was because of a pretty obvious, but stupid, error on my part .
tldr; Use the full command line to run the tests (e.g. python3 -m unittest tests.module_name.TestClass.test_func
) or if you're using a bash function, make sure the function accepts other arguments.
I had setup a bash function called run_tests
to run unittests and I was trying to specify the module name and test name after calling that method. I.e. I had the following in .bash_profile:
run_tests ()
{
python3 -m unittest
}
and on the terminal, I did:
run_tests tests.module_name.TestClass.test_func
Since the bash function was not setup to accept arguments, the specific test I wanted to run wasn't actually being passed as an argument to unittest.
Obviously, using -v
makes no difference if you use the run_tests
function to try and run a specific test.
When I tested with the -v
option, I used the full command python3 -m unittest -v tests.module_name.TestClass.test_func
which is why I thought the -v
option made it work. To test whether the -v
option actually worked, I was lazy and ran run_tests tests.module_name.TestClass.test_func
again since it was in my shell history instead of typing out the full command, which is what caused this confusion.