[pywin32-checkins] pywin32/com/win32com/test testPyComTest.py,1.19,1.20
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2005-05-31 12:36:21
|
Update of /cvsroot/pywin32/pywin32/com/win32com/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24405/test Modified Files: testPyComTest.py Log Message: With help from Roger Upole: * Add PyObject_AsCurrency and PyObject_FromCurrency to convert CY/CURRENCY structs to/from Python objects. * Invent a pythoncom.__future_currency__ scheme, allowing us to move from the current brain-dead (hiword, loword) currency support into a decimal.Decimal() object. See win32com\readme.html for more details. Index: testPyComTest.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/test/testPyComTest.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** testPyComTest.py 4 May 2004 07:01:13 -0000 1.19 --- testPyComTest.py 31 May 2005 12:36:03 -0000 1.20 *************** *** 113,116 **** --- 113,127 ---- if o.LongProp != 3 or o.IntProp != 3: raise error, "Property value wrong - got %d/%d" % (o.LongProp,o.IntProp) + # currency. + pythoncom.__future_currency__ = 1 + if o.CurrencyProp != 0: + raise error, "Expecting 0, got %r" % (o.CurrencyProp,) + try: + import decimal + except ImportError: + import win32com.decimal_23 as decimal + o.CurrencyProp = decimal.Decimal("1234.5678") + if o.CurrencyProp != decimal.Decimal("1234.5678"): + raise error, "got %r" % (o.CurrencyProp,) def TestGenerated(): *************** *** 208,211 **** --- 219,235 ---- raise error, "Property value wrong - got %d/%d" % (o.LongProp,o.IntProp) + # currency. + pythoncom.__future_currency__ = 1 + if o.CurrencyProp != 0: + raise error, "Expecting 0, got %r" % (o.CurrencyProp,) + try: + import decimal + except ImportError: + import win32com.decimal_23 as decimal + for val in ("1234.5678", "1234.56", "1234"): + o.CurrencyProp = decimal.Decimal(val) + if o.CurrencyProp != decimal.Decimal(val): + raise error, "%s got %r" % (val, o.CurrencyProp) + # Do the connection point thing... # Create a connection object. |