[pywin32-checkins] pywin32/win32/test test_win32file.py,1.4,1.5
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2004-10-09 01:42:17
|
Update of /cvsroot/pywin32/pywin32/win32/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1340 Modified Files: test_win32file.py Log Message: Test code via [ 979270 ] SetFilePointer fails with negative offset (even though the bug was previously fixed) Index: test_win32file.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/test_win32file.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** test_win32file.py 8 Oct 2004 23:16:27 -0000 1.4 --- test_win32file.py 9 Oct 2004 01:42:01 -0000 1.5 *************** *** 74,77 **** --- 74,115 ---- self.failUnless(not os.path.isfile(testName), "After closing the file, it still exists!") + def testFilePointer(self): + # via [ 979270 ] SetFilePointer fails with negative offset + + # Create a file in the %TEMP% directory. + filename = os.path.join( win32api.GetTempPath(), "win32filetest.dat" ) + + f = win32file.CreateFile(filename, + win32file.GENERIC_READ|win32file.GENERIC_WRITE, + 0, + None, + win32file.CREATE_ALWAYS, + win32file.FILE_ATTRIBUTE_NORMAL, + 0) + try: + #Write some data + data = 'Some data' + (res, written) = win32file.WriteFile(f, data) + + self.failIf(res) + self.assertEqual(written, len(data)) + + #Move at the beginning and read the data + win32file.SetFilePointer(f, 0, win32file.FILE_BEGIN) + (res, s) = win32file.ReadFile(f, len(data)) + + self.failIf(res) + self.assertEqual(s, data) + + #Move at the end and read the data + win32file.SetFilePointer(f, -len(data), win32file.FILE_END) + (res, s) = win32file.ReadFile(f, len(data)) + + self.failIf(res) + self.failUnlessEqual(s, data) + finally: + f.Close() + os.unlink(filename) + class TestOverlapped(unittest.TestCase): def testSimpleOverlapped(self): |