flake8/run_tests.py
Ian Cordasco 1e59072600 Start new tests
run_tests will collect and run the tests on python 2.6+ (need to test 2.5)
without nose.
2013-07-04 13:47:01 -04:00

32 lines
913 B
Python
Executable file

#!/usr/bin/env python
import unittest
import os
import re
import sys
sys.path.insert(0, '.')
TEST_DIR = 'flake8.tests'
def collect_tests():
# list files in directory tests/
names = os.listdir(TEST_DIR.replace('.', '/'))
regex = re.compile("(?!_+)\w+\.py$")
join = '.'.join
# Make a list of the names like 'tests.test_name'
names = [join([TEST_DIR, f[:-3]]) for f in names if regex.match(f)]
modules = [__import__(name, fromlist=[TEST_DIR]) for name in names]
load_tests = unittest.defaultTestLoader.loadTestsFromModule
suites = [load_tests(m) for m in modules]
suite = suites.pop()
for s in suites:
suite.addTests(s)
return suite
if __name__ == "__main__":
suite = collect_tests()
res = unittest.TextTestRunner(verbosity=1).run(suite)
# If it was successful, we don't want to exit with code 1
raise SystemExit(not res.wasSuccessful())