Joe Gregorio | 48d361f | 2010-08-18 13:19:21 -0400 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | import glob, unittest, os, sys |
| 3 | |
| 4 | from trace import fullmodname |
| 5 | try: |
| 6 | from tests.utils import cleanup |
| 7 | except: |
| 8 | def cleanup(): |
| 9 | pass |
| 10 | |
| 11 | sys.path.insert(0, os.getcwd()) |
| 12 | |
| 13 | # find all of the test modules |
| 14 | modules = map(fullmodname, glob.glob(os.path.join('tests', 'test_*.py'))) |
| 15 | print "Running the tests found in the following modules:" |
| 16 | print modules |
| 17 | |
| 18 | # load all of the tests into a suite |
| 19 | try: |
| 20 | suite = unittest.TestLoader().loadTestsFromNames(modules) |
| 21 | except Exception, exception: |
| 22 | # attempt to produce a more specific message |
| 23 | for module in modules: |
| 24 | __import__(module) |
| 25 | raise |
| 26 | |
| 27 | verbosity = 1 |
| 28 | if "-q" in sys.argv or '--quiet' in sys.argv: |
| 29 | verbosity = 0 |
| 30 | if "-v" in sys.argv or '--verbose' in sys.argv: |
| 31 | verbosity = 2 |
| 32 | |
| 33 | # run test suite |
| 34 | unittest.TextTestRunner(verbosity=verbosity).run(suite) |
| 35 | |
| 36 | cleanup() |
| 37 | |