]> git.phdru.name Git - sqlconvert.git/blob - tests/run_all.py
Move requote_names from process_tokens.py to process_mysql.py
[sqlconvert.git] / tests / run_all.py
1 #! /usr/bin/env python
2 from __future__ import print_function
3
4
5 import os
6 import sys
7 import subprocess
8
9
10 def isexecutable(filename):
11     infile = open(filename, 'r')
12     magic = infile.read(2)
13     infile.close()
14     return magic == "#!"
15
16
17 def collect_tests():
18     tests = []
19     for dirpath, dirs, files in os.walk("tests"):
20         tests.extend(
21             [os.path.join(dirpath, filename) for filename in files
22              if filename.startswith("test") and filename.endswith(".py")
23              ])
24     return [test[:-3].replace(os.sep, '.') for test in tests
25             if isexecutable(test)]
26
27
28 def main():
29     os.chdir(os.path.join(os.path.dirname(sys.argv[0]), os.pardir))
30     tests = collect_tests()
31
32     os.environ["PYTHONPATH"] = os.curdir
33
34     for test in sorted(tests):
35         print(test)
36         subprocess.call((sys.executable, '-m', test))
37
38 if __name__ == '__main__':
39     main()