Start new tests

run_tests will collect and run the tests on python 2.6+ (need to test 2.5)
without nose.
This commit is contained in:
Ian Cordasco 2013-07-04 13:47:01 -04:00
parent 3fbfd0b2d7
commit 1e59072600
2 changed files with 40 additions and 0 deletions

View file

@ -0,0 +1,8 @@
from flake8 import engine
import unittest
class TestEngine(unittest.TestCase):
def test_get_style_guide(self):
g = engine.get_style_guide()
self.assertTrue(isinstance(g, engine.StyleGuide))

32
run_tests.py Executable file
View file

@ -0,0 +1,32 @@
#!/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())