|
| 1 | +importsys |
| 2 | +importos |
| 3 | +importglob |
| 4 | +importunittest |
| 5 | + |
| 6 | +#Allow us to import the parent module |
| 7 | +os.chdir(os.path.split(os.path.abspath(__file__))[0]) |
| 8 | +sys.path.insert(0,os.path.abspath(os.curdir)) |
| 9 | +sys.path.insert(0,os.path.abspath(os.pardir)) |
| 10 | +sys.path.insert(0,os.path.join(os.path.abspath(os.pardir),"src")) |
| 11 | + |
| 12 | +defbuildTestSuite(): |
| 13 | +suite=unittest.TestSuite() |
| 14 | +fortestcaseinglob.glob('test_*.py'): |
| 15 | +iftestcasein ("test_tokenizer.py","test_parser.py","test_parser2.py"): |
| 16 | +module=os.path.splitext(testcase)[0] |
| 17 | +suite.addTest(__import__(module).buildTestSuite()) |
| 18 | +returnsuite |
| 19 | + |
| 20 | +defmain(): |
| 21 | +results=unittest.TextTestRunner().run(buildTestSuite()) |
| 22 | +returnresults |
| 23 | + |
| 24 | +if__name__=="__main__": |
| 25 | +results=main() |
| 26 | +ifnotresults.wasSuccessful(): |
| 27 | +sys.exit(1) |