import os import sys import unittest import cStringIO def setup_th(): from th import Ifc Ifc.messages = [] def msg(s, do_pk=True): Ifc.messages.append(s) Ifc.msg = msg def color(*a): return '' Ifc.color, Ifc.orig_color = color, Ifc.color Ifc.inputs = [] def getch(*a): return Ifc.inputs.pop(0) Ifc.getch = Ifc.gstring = getch from th import g from th.data import Species g.player = Species.hamster.make() g.phase = 1 g.player.fmt = { 's':'', 'es': '', 'do': 'do', 'you': 'you', 'youm': 'you', 'your': 'your', 'are': 'are', 've': 've' } def main(): test_dir = os.path.dirname(os.path.abspath(__file__)) tests = os.listdir(test_dir) tests = ['th.test.%s' % test[:-3] for test in tests if test.endswith('.py') and test.startswith('test_')] all_tests = unittest.TestSuite() for test in tests: test_mod = __import__(test, globals(), locals(), [test]) test_suite = unittest.TestSuite() for test_cls in test_mod.tests: test_suite.addTest(unittest.makeSuite(test_cls)) all_tests.addTest(test_suite) runner = unittest.TextTestRunner(verbosity=2) setup_th() sys.stdout = cStringIO.StringIO() runner.run(all_tests)