home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- import sys
- import win32com.server.util as win32com
- import win32com.test.util as win32com
- import win32com.client as win32com
- import traceback
- import pythoncom
- import pywintypes
- import winerror
- L = pywintypes.Unicode
- import unittest
- error = 'dictionary test error'
-
- def MakeTestDictionary():
- return win32com.client.Dispatch('Python.Dictionary')
-
-
- def TestDictAgainst(dict, check):
- for key, value in check.items():
- if dict(key) != value:
- raise error, "Indexing for '%s' gave the incorrect value - %s/%s" % (`key`, `dict[key]`, `check[key]`)
- dict(key) != value
-
-
-
- def Register(quiet):
- import win32com.server.register as win32com
- DictionaryPolicy = DictionaryPolicy
- import win32com.servers.dictionary
- win32com.server.register.RegisterClasses(DictionaryPolicy, quiet = quiet)
-
-
- def TestDict(quiet = None):
- if quiet is None:
- quiet = '-v' not in sys.argv
-
- Register(quiet)
- if not quiet:
- print 'Simple enum test'
-
- dict = MakeTestDictionary()
- checkDict = { }
- TestDictAgainst(dict, checkDict)
- dict['NewKey'] = 'NewValue'
- checkDict['NewKey'] = 'NewValue'
- TestDictAgainst(dict, checkDict)
- dict['NewKey'] = None
- del checkDict['NewKey']
- TestDictAgainst(dict, checkDict)
- if not quiet:
- print 'Failure tests'
-
-
- try:
- dict()
- raise error, 'default method with no args worked when it shouldnt have!'
- except pythoncom.com_error:
- (hr, desc, exc, argErr) = None
- if hr != winerror.DISP_E_BADPARAMCOUNT:
- raise error, 'Expected DISP_E_BADPARAMCOUNT - got %d (%s)' % (hr, desc)
- hr != winerror.DISP_E_BADPARAMCOUNT
-
-
- try:
- dict('hi', 'there')
- raise error, 'multiple args worked when it shouldnt have!'
- except pythoncom.com_error:
- (hr, desc, exc, argErr) = None
- if hr != winerror.DISP_E_BADPARAMCOUNT:
- raise error, 'Expected DISP_E_BADPARAMCOUNT - got %d (%s)' % (hr, desc)
- hr != winerror.DISP_E_BADPARAMCOUNT
-
-
- try:
- dict(0)
- raise error, 'int key worked when it shouldnt have!'
- except pythoncom.com_error:
- (hr, desc, exc, argErr) = None
- if hr != winerror.DISP_E_TYPEMISMATCH:
- raise error, 'Expected DISP_E_TYPEMISMATCH - got %d (%s)' % (hr, desc)
- hr != winerror.DISP_E_TYPEMISMATCH
-
- if not quiet:
- print 'Python.Dictionary tests complete.'
-
-
-
- class TestCase(win32com.test.util.TestCase):
-
- def testDict(self):
- TestDict()
-
-
- if __name__ == '__main__':
- unittest.main()
-
-