[pywin32-checkins] pywin32/win32/test test_win32trace.py,1.2,1.3
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: <mha...@us...> - 2003-10-23 10:21:16
|
Update of /cvsroot/pywin32/pywin32/win32/test In directory sc8-pr-cvs1:/tmp/cvs-serv13176 Modified Files: test_win32trace.py Log Message: Allow this to work even when run by an external file, and make some basic cehcks that no other reader is running, as this can cause our tests to hang. Index: test_win32trace.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/test_win32trace.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_win32trace.py 31 Aug 2003 04:47:57 -0000 1.2 --- test_win32trace.py 23 Oct 2003 05:16:02 -0000 1.3 *************** *** 6,9 **** --- 6,24 ---- import sys + if __name__=='__main__': + this_file = sys.argv[0] + else: + this_file = __file__ + + def CheckNoOtherWriters(): + win32trace.write("Hi") + time.sleep(0.05) + if win32trace.read() != "Hi": + # Reset everything so following tests still fail with this error!S + win32trace.TermRead() + win32trace.TermWrite() + raise RuntimeError, "An existing win32trace reader appears to be " \ + "running - please stop this process and try again" + class TestInitOps(unittest.TestCase): def tearDown(self): *************** *** 127,130 **** --- 142,146 ---- win32trace.InitRead() win32trace.InitWrite() + CheckNoOtherWriters() self.threads = [WriterThread() for each in range(self.FullBucket)] self.buckets = range(self.BucketCount) *************** *** 196,200 **** procHandle, threadHandle, procId, threadId = win32process.CreateProcess( None, # appName ! 'python.exe %s /run_test_process %s %s' % (sys.argv[0], self.BucketCount, self.threadCount), --- 212,216 ---- procHandle, threadHandle, procId, threadId = win32process.CreateProcess( None, # appName ! 'python.exe %s /run_test_process %s %s' % (this_file, self.BucketCount, self.threadCount), |