My testing script looks as follows:
import os
import sys
from unittest import defaultTestLoader as loader, TextTestRunner
path_to_my_project = os.path.dirnam
I had some trouble getting TextTestRunner
results. For those like me, here is how it works:
"""Run all tests inside of *_test.py modules located in the same directory."""
import sys
import unittest
if __name__ == '__main__':
test_suite = unittest.defaultTestLoader.discover('.', '*_test.py')
test_runner = unittest.TextTestRunner(resultclass=unittest.TextTestResult)
result = test_runner.run(test_suite)
sys.exit(not result.wasSuccessful())
The code is not using unittest.main. You need to check the result using TestResult.wasSuccessful and call sys.exit manually.
import sys
....
ret = not runner.run(suite).wasSuccessful()
sys.exit(ret)