[pywin32-checkins] pywin32/com/win32com/test testPyComTest.py, 1.41, 1.42
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2009-01-04 22:35:50
|
Update of /cvsroot/pywin32/pywin32/com/win32com/test In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv10927/test Modified Files: testPyComTest.py Log Message: Use py3k friendly way of getting a long int for testing Index: testPyComTest.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/test/testPyComTest.py,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** testPyComTest.py 19 Dec 2008 01:52:35 -0000 1.41 --- testPyComTest.py 4 Jan 2009 22:35:44 -0000 1.42 *************** *** 3,10 **** import sys; sys.coinit_flags=0 # Must be free-threaded! ! import win32api, types, pythoncom, time import sys, os, win32com, win32com.client.connect from win32com.test.util import CheckClean ! from win32com.client import constants import win32com from win32com.test.util import RegisterPythonServer --- 3,10 ---- import sys; sys.coinit_flags=0 # Must be free-threaded! ! import win32api, pythoncom, time import sys, os, win32com, win32com.client.connect from win32com.test.util import CheckClean ! from win32com.client import constants, DispatchBaseClass import win32com from win32com.test.util import RegisterPythonServer *************** *** 33,36 **** --- 33,45 ---- verbose = 0 + # convert a normal int to a long int - used to avoid, eg, '1L' for py3k + # friendliness + def ensure_long(int_val): + if sys.version_info > (3,): + # py3k - no such thing as a 'long' + return int_val + # on py2x, we just use an expression that results in a long + return 0x100000000-0x100000000+int_val + def progress(*args): if verbose: *************** *** 180,184 **** i1, i2 = o.GetMultipleInterfaces() ! if type(i1) != types.InstanceType or type(i2) != types.InstanceType: # Yay - is now an instance returned! raise error("GetMultipleInterfaces did not return instances - got '%s', '%s'" % (i1, i2)) --- 189,193 ---- i1, i2 = o.GetMultipleInterfaces() ! if not isinstance(i1, DispatchBaseClass) or not isinstance(i2, DispatchBaseClass): # Yay - is now an instance returned! raise error("GetMultipleInterfaces did not return instances - got '%s', '%s'" % (i1, i2)) *************** *** 212,216 **** raise error("GetSetUnknown failed") progress("Checking getting/passing IDispatch") ! if type(o.GetSetDispatch(o)) !=types.InstanceType: raise error("GetSetDispatch failed") progress("Checking getting/passing IDispatch of known type") --- 221,225 ---- raise error("GetSetUnknown failed") progress("Checking getting/passing IDispatch") ! if not isinstance(o.GetSetDispatch(o), DispatchBaseClass): raise error("GetSetDispatch failed") progress("Checking getting/passing IDispatch of known type") *************** *** 223,227 **** if o.GetSetVariant(o) != o: raise error("GetSetVariant (dispatch) failed") ! for l in sys.maxint, sys.maxint+1, 1 << 65L: if o.GetSetVariant(l) != l: raise error("GetSetVariant (long) failed") --- 232,239 ---- if o.GetSetVariant(o) != o: raise error("GetSetVariant (dispatch) failed") ! # We want to explicitly test > 32 bits. py3k has no 'maxint' and ! # 'maxsize+1' is no good on 64bit platforms as its 65 bits! ! big = 2147483647 # sys.maxint on py2k ! for l in big, big+1, 1 << 65: if o.GetSetVariant(l) != l: raise error("GetSetVariant (long) failed") *************** *** 271,278 **** TestApplyResult(o.Test6, (constants.WideAttr5,), constants.WideAttr5) ! TestConstant("ULongTest1", 0xFFFFFFFFL) ! TestConstant("ULongTest2", 0x7FFFFFFFL) ! TestConstant("LongTest1", -0x7FFFFFFFL) ! TestConstant("LongTest2", 0x7FFFFFFFL) TestConstant("UCharTest", 255) TestConstant("CharTest", -1) --- 283,290 ---- TestApplyResult(o.Test6, (constants.WideAttr5,), constants.WideAttr5) ! TestConstant("ULongTest1", ensure_long(0xFFFFFFFF)) ! TestConstant("ULongTest2", ensure_long(0x7FFFFFFF)) ! TestConstant("LongTest1", ensure_long(-0x7FFFFFFF)) ! TestConstant("LongTest2", ensure_long(0x7FFFFFFF)) TestConstant("UCharTest", 255) TestConstant("CharTest", -1) |