[pywin32-checkins] pywin32/win32/test testall.py,1.5,1.6
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2007-05-29 12:22:29
|
Update of /cvsroot/pywin32/pywin32/win32/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22633 Modified Files: testall.py Log Message: run the majority of the demos as part of the tests Index: testall.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/testall.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** testall.py 24 May 2007 05:39:13 -0000 1.5 --- testall.py 29 May 2007 12:22:28 -0000 1.6 *************** *** 2,8 **** import unittest def import_all(): # Some hacks for import order - dde depends on win32ui ! import win32ui import win32api --- 2,60 ---- import unittest + # A list of demos that depend on user-interface of *any* kind. Tests listed + # here are not suitable for unattended testing. + ui_demos = """GetSaveFileName print_desktop win32cred_demo win32gui_demo + win32gui_dialog win32gui_menu win32gui_taskbar + win32rcparser_demo winprocess win32console_demo""".split() + # Other demos known as 'bad' (or at least highly unlikely to work) + # cerapi: no CE module is built (CE via pywin32 appears dead) + # desktopmanager: hangs (well, hangs for 60secs or so...) + bad_demos = "cerapi desktopmanager win32comport_demo".split() + + argvs = { + "rastest": ("-l",), + } + + ok_exceptions = { + "RegCreateKeyTransacted": ("NotImplementedError"), + } + + class TestRunner: + def __init__(self, argv): + self.argv = argv + def __call__(self): + # subprocess failed in strange ways for me?? + fin, fout, ferr = os.popen3(" ".join(self.argv)) + fin.close() + output = fout.read() + ferr.read() + fout.close() + rc = ferr.close() + if rc: + base = os.path.basename(self.argv[1]) + raise AssertionError, "%s failed with exit code %s. Output is:\n%s" % (base, rc, output) + + def get_demo_tests(): + import win32api + ret = [] + demo_dir = os.path.abspath(os.path.join(os.path.dirname(win32api.__file__), "Demos")) + assert os.path.isdir(demo_dir), demo_dir + for name in os.listdir(demo_dir): + base, ext = os.path.splitext(name) + if ext != ".py" or base in ui_demos or base in bad_demos: + continue + if base in ok_exceptions: + print "Ack - can't handle test %s - can't catch specific exceptions" % (base,) + continue + argv = (sys.executable, os.path.join(demo_dir, base+".py")) + \ + argvs.get(base, ()) + ret.append(unittest.FunctionTestCase(TestRunner(argv), description="win32/demos/" + name)) + return ret + def import_all(): # Some hacks for import order - dde depends on win32ui ! try: ! import win32ui ! except ImportError: ! pass # 'what-ev-a....' import win32api *************** *** 47,50 **** --- 99,104 ---- test = unittest.defaultTestLoader.loadTestsFromModule(mod) suite.addTest(test) + for test in get_demo_tests(): + suite.addTest(test) return suite |