I have directories, which contain files named like:
test_foo.py
Each file is a test case.
I would like to
Run all the tests in a direc
Once you have discovered tests, you can run them with a test runner.
For Python 2:
import unittest2
loader = unittest2.TestLoader()
tests = loader.discover('.')
testRunner = unittest2.runner.TextTestRunner()
testRunner.run(tests)
For Python 3:
import unittest
loader = unittest.TestLoader()
tests = loader.discover('.')
testRunner = unittest.runner.TextTestRunner()
testRunner.run(tests)
Running the above code will print the test results to standard out.