[pywin32-checkins] pywin32/win32/test test_win32file.py,1.29,1.30
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2009-01-26 01:23:15
|
Update of /cvsroot/pywin32/pywin32/win32/test In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv11971/win32/test Modified Files: test_win32file.py Log Message: make new tests py3k-friendly Index: test_win32file.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/test_win32file.py,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** test_win32file.py 26 Jan 2009 00:47:31 -0000 1.29 --- test_win32file.py 26 Jan 2009 01:23:09 -0000 1.30 *************** *** 595,599 **** cli, addr = s1.accept() self.request = cli.recv(1024) ! cli.send('some expected response') t = threading.Thread(target=runner) t.start() --- 595,599 ---- cli, addr = s1.accept() self.request = cli.recv(1024) ! cli.send(str2bytes('some expected response')) t = threading.Thread(target=runner) t.start() *************** *** 602,606 **** ol = pywintypes.OVERLAPPED() s2.bind(('0.0.0.0', 0)) # connectex requires the socket be bound beforehand ! win32file.ConnectEx(s2, self.addr, ol, "some expected request") win32file.GetOverlappedResult(s2.fileno(), ol, 1) ol = pywintypes.OVERLAPPED() --- 602,606 ---- ol = pywintypes.OVERLAPPED() s2.bind(('0.0.0.0', 0)) # connectex requires the socket be bound beforehand ! win32file.ConnectEx(s2, self.addr, ol, str2bytes("some expected request")) win32file.GetOverlappedResult(s2.fileno(), ol, 1) ol = pywintypes.OVERLAPPED() *************** *** 609,614 **** length = win32file.GetOverlappedResult(s2.fileno(), ol, 1) self.response = buff[:length] ! self.assertEqual(self.response, 'some expected response') ! self.assertEqual(self.request, 'some expected request') t.join(5) self.failIf(t.isAlive(), "worker thread didn't terminate") --- 609,614 ---- length = win32file.GetOverlappedResult(s2.fileno(), ol, 1) self.response = buff[:length] ! self.assertEqual(self.response, str2bytes('some expected response')) ! self.assertEqual(self.request, str2bytes('some expected request')) t.join(5) self.failIf(t.isAlive(), "worker thread didn't terminate") *************** *** 621,625 **** s1.listen(1) cli, addr = s1.accept() ! cli.send('some expected response') t = threading.Thread(target=runner) t.start() --- 621,625 ---- s1.listen(1) cli, addr = s1.accept() ! cli.send(str2bytes('some expected response')) t = threading.Thread(target=runner) t.start() *************** *** 635,639 **** length = win32file.GetOverlappedResult(s2.fileno(), ol, 1) self.response = buff[:length] ! self.assertEqual(self.response, 'some expected response') t.join(5) self.failIf(t.isAlive(), "worker thread didn't terminate") --- 635,639 ---- length = win32file.GetOverlappedResult(s2.fileno(), ol, 1) self.response = buff[:length] ! self.assertEqual(self.response, str2bytes('some expected response')) t.join(5) self.failIf(t.isAlive(), "worker thread didn't terminate") *************** *** 666,670 **** length = 0 ! ol = pywintypes.OVERLAPPED() f.seek(0) --- 666,674 ---- length = 0 ! aaa = str2bytes("[AAA]") ! bbb = str2bytes("[BBB]") ! ccc = str2bytes("[CCC]") ! ddd = str2bytes("[DDD]") ! empty = str2bytes("") ol = pywintypes.OVERLAPPED() f.seek(0) *************** *** 674,700 **** ol = pywintypes.OVERLAPPED() f.seek(0) ! win32file.TransmitFile(s2, win32file._get_osfhandle(f.fileno()), val_length, 0, ol, 0, "[AAA]", "[BBB]") length += win32file.GetOverlappedResult(s2.fileno(), ol, 1) ol = pywintypes.OVERLAPPED() f.seek(0) ! win32file.TransmitFile(s2, win32file._get_osfhandle(f.fileno()), val_length, 0, ol, 0, "", "") length += win32file.GetOverlappedResult(s2.fileno(), ol, 1) ol = pywintypes.OVERLAPPED() f.seek(0) ! win32file.TransmitFile(s2, win32file._get_osfhandle(f.fileno()), val_length, 0, ol, 0, None, "[CCC]") length += win32file.GetOverlappedResult(s2.fileno(), ol, 1) ol = pywintypes.OVERLAPPED() f.seek(0) ! win32file.TransmitFile(s2, win32file._get_osfhandle(f.fileno()), val_length, 0, ol, 0, "[DDD]") length += win32file.GetOverlappedResult(s2.fileno(), ol, 1) s2.close() th.join() ! buf = ''.join(self.request) self.assertEqual(length, len(buf)) ! self.assert_(("%s[AAA]%s[BBB]%s%s[CCC][DDD]%s" % (val,val,val,val,val)) == buf) --- 678,706 ---- ol = pywintypes.OVERLAPPED() f.seek(0) ! win32file.TransmitFile(s2, win32file._get_osfhandle(f.fileno()), val_length, 0, ol, 0, aaa, bbb) length += win32file.GetOverlappedResult(s2.fileno(), ol, 1) ol = pywintypes.OVERLAPPED() f.seek(0) ! win32file.TransmitFile(s2, win32file._get_osfhandle(f.fileno()), val_length, 0, ol, 0, empty, empty) length += win32file.GetOverlappedResult(s2.fileno(), ol, 1) ol = pywintypes.OVERLAPPED() f.seek(0) ! win32file.TransmitFile(s2, win32file._get_osfhandle(f.fileno()), val_length, 0, ol, 0, None, ccc) length += win32file.GetOverlappedResult(s2.fileno(), ol, 1) ol = pywintypes.OVERLAPPED() f.seek(0) ! win32file.TransmitFile(s2, win32file._get_osfhandle(f.fileno()), val_length, 0, ol, 0, ddd) length += win32file.GetOverlappedResult(s2.fileno(), ol, 1) s2.close() th.join() ! buf = str2bytes('').join(self.request) self.assertEqual(length, len(buf)) ! expected = val + aaa + val + bbb + val + val + ccc + ddd + val ! self.assertEqual(type(expected), type(buf)) ! self.assert_(expected == buf) |