added thirdparty testing (test/completion/thirdparty/) and fixed an AttributeError

This commit is contained in:
David Halter
2012-06-25 21:05:10 +02:00
parent 2f70c67ada
commit e7a579ce31
3 changed files with 31 additions and 12 deletions

View File

@@ -121,17 +121,27 @@ def run_test(source):
completion_test_dir = 'test/completion'
summary = []
tests_pass = True
for f_name in os.listdir(completion_test_dir):
if len(sys.argv) == 1 or [a for a in sys.argv[1:] if a in f_name]:
if f_name.endswith(".py"):
path = os.path.join(completion_test_dir, f_name)
f = open(path)
num_tests, fails = run_test(f.read())
s = 'run %s tests with %s fails (%s)' % (num_tests, fails, f_name)
if fails:
tests_pass = False
print(s)
summary.append(s)
def test_dir(completion_test_dir, third_party=False):
global tests_pass
for f_name in os.listdir(completion_test_dir):
if len(sys.argv) == 1 or [a for a in sys.argv[1:] if a in f_name]:
if f_name.endswith(".py"):
if third_party:
try:
__import__(f_name.replace('.py', ''))
except ImportError:
summary.append('Thirdparty-Library %s not found.' % f_name)
path = os.path.join(completion_test_dir, f_name)
f = open(path)
num_tests, fails = run_test(f.read())
s = 'run %s tests with %s fails (%s)' % (num_tests, fails, f_name)
if fails:
tests_pass = False
print(s)
summary.append(s)
test_dir(completion_test_dir)
test_dir(completion_test_dir + '/thirdparty', third_party=True)
print('\nSummary:')
for s in summary: