File: run_tests.py

package info (click to toggle)
pygame 1.7.1release-4.2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 3,344 kB
  • ctags: 2,290
  • sloc: ansic: 18,530; python: 4,527; makefile: 54
file content (25 lines) | stat: -rwxr-xr-x 725 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env python
import sys, os, re, unittest

main_dir = os.path.split(os.path.abspath(sys.argv[0]))[0]
test_subdir = 'test'

# Make sure we're in the correct directory
os.chdir( main_dir )

# Add the modules directory to the python path    
sys.path.insert( 0, test_subdir )

# Load all the tests
suite = unittest.TestSuite()
test_module_re = re.compile('^(.+_test)\.py$')
for file in os.listdir(test_subdir):
    for module in test_module_re.findall(file):
        print 'loading ' + module
        __import__( module )
        test = unittest.defaultTestLoader.loadTestsFromName( module )
        suite.addTest( test )

# Run the tests
runner = unittest.TextTestRunner()
runner.run( suite )