3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-27 21:19:31 +01:00

runtests: remove .py extension, only run tests when ran as a script

This commit is contained in:
James Lu 2016-03-11 23:04:02 -08:00
parent da7bd649d2
commit 2adb67d38e
2 changed files with 26 additions and 24 deletions

26
runtests Executable file
View File

@ -0,0 +1,26 @@
#!/usr/bin/env python3
import unittest
import glob
import os
import sys
if __name__ == '__main__':
runner = unittest.TextTestRunner(verbosity=2)
fails = []
suites = []
# Yay, import hacks!
sys.path.append(os.path.join(os.getcwd(), 'tests'))
query = sys.argv[1:] or glob.glob('tests/test_*.py')
for testfile in query:
# Strip the tests/ and .py extension: tests/test_whatever.py => test_whatever
module = testfile.replace('.py', '').replace('tests/', '')
module = __import__(module)
suites.append(unittest.defaultTestLoader.loadTestsFromModule(module))
testsuite = unittest.TestSuite(suites)
runner.run(testsuite)

View File

@ -1,24 +0,0 @@
#!/usr/bin/env python3
import unittest
import glob
import os
import sys
runner = unittest.TextTestRunner(verbosity=2)
fails = []
suites = []
# Yay, import hacks!
sys.path.append(os.path.join(os.getcwd(), 'tests'))
query = sys.argv[1:] or glob.glob('tests/test_*.py')
for testfile in query:
# Strip the tests/ and .py extension: tests/test_whatever.py => test_whatever
module = testfile.replace('.py', '').replace('tests/', '')
module = __import__(module)
suites.append(unittest.defaultTestLoader.loadTestsFromModule(module))
testsuite = unittest.TestSuite(suites)
runner.run(testsuite)