[pywin32-checkins] pywin32/com/win32com/test testClipboard.py, 1.2, 1.3
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2008-11-26 01:20:34
|
Update of /cvsroot/pywin32/pywin32/com/win32com/test In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv13616 Modified Files: testClipboard.py Log Message: Make test py3k friendly Index: testClipboard.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/test/testClipboard.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** testClipboard.py 4 May 2004 07:02:30 -0000 1.2 --- testClipboard.py 26 Nov 2008 01:20:23 -0000 1.3 *************** *** 46,50 **** if cf == win32con.CF_TEXT: ret_stg = pythoncom.STGMEDIUM() ! ret_stg.set(pythoncom.TYMED_HGLOBAL, self.strval) elif cf == win32con.CF_UNICODETEXT: ret_stg = pythoncom.STGMEDIUM() --- 46,51 ---- if cf == win32con.CF_TEXT: ret_stg = pythoncom.STGMEDIUM() ! # ensure always 'bytes' by encoding string. ! ret_stg.set(pythoncom.TYMED_HGLOBAL, self.strval.encode("ascii")) elif cf == win32con.CF_UNICODETEXT: ret_stg = pythoncom.STGMEDIUM() *************** *** 110,114 **** win32clipboard.OpenClipboard() got = win32clipboard.GetClipboardData(win32con.CF_TEXT) ! self.assertEqual(got, "Hello from Python") # Now check unicode got = win32clipboard.GetClipboardData(win32con.CF_UNICODETEXT) --- 111,117 ---- win32clipboard.OpenClipboard() got = win32clipboard.GetClipboardData(win32con.CF_TEXT) ! # CF_TEXT gives bytes on py3k - use encode() to ensure that's true. ! expected = "Hello from Python".encode("ascii") ! self.assertEqual(got, expected) # Now check unicode got = win32clipboard.GetClipboardData(win32con.CF_UNICODETEXT) *************** *** 118,122 **** def testWin32ToCom(self): # Set the data via the std win32 clipboard functions. ! val = "Hello again!" win32clipboard.OpenClipboard() win32clipboard.SetClipboardData(win32con.CF_TEXT, val) --- 121,125 ---- def testWin32ToCom(self): # Set the data via the std win32 clipboard functions. ! val = "Hello again!".encode("ascii") # ensure always bytes, even in py3k win32clipboard.OpenClipboard() win32clipboard.SetClipboardData(win32con.CF_TEXT, val) *************** *** 130,134 **** # knowing if it meant to be a string, or a binary buffer, so # it must return it too. ! self.failUnlessEqual(got, val+"\0") def testDataObjectFlush(self): --- 133,137 ---- # knowing if it meant to be a string, or a binary buffer, so # it must return it too. ! self.failUnlessEqual(got, "Hello again!\0".encode("ascii")) def testDataObjectFlush(self): *************** *** 152,155 **** if __name__=='__main__': ! import util util.testmain() --- 155,158 ---- if __name__=='__main__': ! from win32com.test import util util.testmain() |