Blue Monday Blue Monday - 23 days ago 6
Python Question

Running unittests in CMD or python IDLE

I couldn't find answers for this anywhere. Is it possible to run the tests.py with unittests in IDLE or CMD?
For example, if there are 3 tests, 1 failed,2 passed I would get the output like:

python tests.py
Test1 failed
Test2 passed
Test3 passed


I tried running the file and it gives me only, one OK.

C:PycharmProjects>python testfin1.py
......
----------------------------------------------------------------------
Ran 6 tests in 0.002s

OK


However I want to get results for all tests, is that possible?

Answer

If all tests are passed, you only get details like below where 6 tests ran and all of them passed.

C:PycharmProjects>python testfin1.py
......
----------------------------------------------------------------------
Ran 6 tests in 0.002s

OK

In case of error it shows the stacktrace with test name that fails. You can look in detail over here.