Update of /cvsroot/pywin32/pywin32/com/win32com/test
In directory sc8-pr-cvs1:/tmp/cvs-serv4895
Modified Files:
testall.py
Log Message:
More tests use UnitTest - but nore critically, testPyCOMTest would
silently fail - fix that!
Index: testall.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/test/testall.py,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** testall.py 31 Oct 2003 13:52:24 -0000 1.17
--- testall.py 2 Nov 2003 10:05:23 -0000 1.18
***************
*** 5,8 ****
--- 5,15 ----
import traceback
+ import unittest
+
+ try:
+ this_file = __file__
+ except NameError:
+ this_file = sys.argv[0]
+
def GenerateAndRunOldStyle():
import GenTestScripts
***************
*** 38,42 ****
print "***** %s test FAILED after %d lines of output" % (desc, capture.get_num_lines_captured())
! unittest_modules = "testIterators testvbscript_regexp".split()
if __name__=='__main__':
--- 45,69 ----
print "***** %s test FAILED after %d lines of output" % (desc, capture.get_num_lines_captured())
! class PyCOMTest(unittest.TestCase):
! def testit(self):
! # Execute testPyComTest in its own process so it can play
! # with the Python thread state
! fname = os.path.join(os.path.dirname(this_file), "testPyComTest.py")
! cmd = '%s "%s" -q 2>&1' % (sys.executable, fname)
! f = os.popen(cmd)
! data = f.read()
! rc = f.close()
! if rc:
! print data
! self.fail("Executing '%s' failed (%d)" % (cmd, rc))
! data = string.strip(data)
! if data:
! print "** testPyCOMTest generated unexpected output"
! # lf -> cr/lf
! print string.join(string.split(data, "\n"), "\r\n")
!
! unittest_modules = """testIterators testvbscript_regexp testStorage
! testStreams testWMI policySemantics testShell testROT
! """.split()
if __name__=='__main__':
***************
*** 51,56 ****
CleanGenerated()
! import unittest
! testRunner = unittest.TextTestRunner(verbosity=1)
for mod_name in unittest_modules:
mod = __import__(mod_name)
--- 78,85 ----
CleanGenerated()
! verbosity = 1
! if "-v" in sys.argv: verbosity += 1
! testRunner = unittest.TextTestRunner(verbosity=verbosity)
! suite = unittest.TestSuite()
for mod_name in unittest_modules:
mod = __import__(mod_name)
***************
*** 59,66 ****
else:
test = unittest.defaultTestLoader.loadTestsFromModule(mod)
! result = testRunner.run(test)
! if not result.wasSuccessful():
! print "*" * 50
! print "Unittest tests failed"
import win32com.test.util
capture = win32com.test.util.CaptureWriter()
--- 88,95 ----
else:
test = unittest.defaultTestLoader.loadTestsFromModule(mod)
! suite.addTest(test)
! suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(PyCOMTest))
! result = testRunner.run(suite)
!
import win32com.test.util
capture = win32com.test.util.CaptureWriter()
***************
*** 81,101 ****
_test_with_import(capture, "testExchange", "test", "MS Exchange")
- _test_with_import(capture, "testStreams", "test", "Streams")
- _test_with_import(capture, "testWMI", "test", "WMI")
-
- # Execute testPyComTest in its own process so it can play
- # with the Python thread state
- import win32pipe
- data = win32pipe.popen(sys.executable + " testPyComTest.py -q").read()
- data = string.strip(data)
- # lf -> cr/lf
- print string.join(string.split(data, "\n"), "\r\n")
-
import errorSemantics
errorSemantics.test()
- import policySemantics
- policySemantics.TestAll()
-
try:
import testvb
--- 110,116 ----
***************
*** 104,108 ****
print why
-
import testAXScript
testAXScript.TestAll()
--- 119,122 ----
***************
*** 148,151 ****
--- 162,169 ----
print "Tests completed."
+ # re-print unit-test error here so it is noticed
+ if not result.wasSuccessful():
+ print "*" * 20, "- unittest tests FAILED"
+
CheckClean()
pythoncom.CoUninitialize()
|