comtypes 1.4.8__zip → 1.4.10__zip

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. {comtypes-1.4.8 → comtypes-1.4.10}/CHANGES.txt +40 -0
  2. {comtypes-1.4.8/comtypes.egg-info → comtypes-1.4.10}/PKG-INFO +4 -3
  3. {comtypes-1.4.8 → comtypes-1.4.10}/README.md +1 -1
  4. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/GUID.py +38 -16
  5. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/__init__.py +36 -16
  6. comtypes-1.4.10/comtypes/_comobject.py +562 -0
  7. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/_memberspec.py +93 -13
  8. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/_meta.py +1 -0
  9. comtypes-1.4.10/comtypes/_post_coinit/_cominterface_meta_patcher.py +152 -0
  10. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/_post_coinit/bstr.py +12 -5
  11. comtypes-1.4.8/comtypes/_py_instance_method.py → comtypes-1.4.10/comtypes/_post_coinit/instancemethod.py +1 -2
  12. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/_post_coinit/misc.py +60 -25
  13. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/_post_coinit/unknwn.py +26 -176
  14. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/_safearray.py +3 -4
  15. comtypes-1.4.10/comtypes/_vtbl.py +448 -0
  16. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/automation.py +46 -49
  17. comtypes-1.4.10/comtypes/client/__init__.py +42 -0
  18. comtypes-1.4.10/comtypes/client/_activeobj.py +46 -0
  19. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/client/_code_cache.py +10 -5
  20. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/client/_constants.py +1 -1
  21. comtypes-1.4.10/comtypes/client/_create.py +147 -0
  22. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/client/_events.py +58 -13
  23. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/client/_generate.py +7 -11
  24. comtypes-1.4.10/comtypes/client/_managing.py +114 -0
  25. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/client/dynamic.py +2 -3
  26. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/client/lazybind.py +12 -13
  27. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/connectionpoints.py +2 -1
  28. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/errorinfo.py +22 -9
  29. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/git.py +5 -5
  30. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/hints.pyi +7 -15
  31. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/logutil.py +15 -3
  32. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/messageloop.py +1 -1
  33. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/persist.py +3 -5
  34. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/safearray.py +17 -5
  35. comtypes-1.4.10/comtypes/server/__init__.py +104 -0
  36. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/server/automation.py +1 -2
  37. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/server/connectionpoints.py +5 -5
  38. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/server/inprocserver.py +25 -17
  39. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/server/localserver.py +49 -19
  40. comtypes-1.4.10/comtypes/server/register.py +478 -0
  41. comtypes-1.4.10/comtypes/server/w_getopt.py +48 -0
  42. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/shelllink.py +16 -33
  43. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/stream.py +7 -4
  44. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/TestComServer.py +6 -7
  45. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/TestDispServer.py +4 -2
  46. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/__init__.py +10 -12
  47. comtypes-1.4.10/comtypes/test/find_memleak.py +72 -0
  48. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/runtests.py +1 -0
  49. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/setup.py +2 -1
  50. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_BSTR.py +10 -23
  51. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_GUID.py +1 -0
  52. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_QueryService.py +1 -0
  53. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_agilent.py +4 -3
  54. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_avmc.py +1 -1
  55. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_basic.py +12 -6
  56. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_casesensitivity.py +3 -5
  57. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_clear_cache.py +1 -1
  58. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_client.py +2 -2
  59. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_client_dynamic.py +2 -2
  60. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_client_regenerate_modules.py +2 -2
  61. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_collections.py +4 -4
  62. comtypes-1.4.10/comtypes/test/test_comobject.py +146 -0
  63. comtypes-1.4.10/comtypes/test/test_comserver.py +349 -0
  64. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_createwrappers.py +2 -4
  65. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_dispifc_records.py +1 -1
  66. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_dispifc_safearrays.py +1 -1
  67. comtypes-1.4.10/comtypes/test/test_dispinterface.py +153 -0
  68. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_dyndispatch.py +1 -0
  69. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_excel.py +22 -12
  70. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_findgendir.py +1 -2
  71. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_getactiveobj.py +4 -4
  72. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_ie.py +19 -9
  73. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_ienum.py +2 -2
  74. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_imfattributes.py +13 -3
  75. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_inout_args.py +8 -5
  76. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_midl_safearray_create.py +14 -4
  77. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_monikers.py +23 -9
  78. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_msscript.py +2 -1
  79. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_npsupport.py +4 -4
  80. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_outparam.py +37 -14
  81. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_persist.py +2 -4
  82. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_recordinfo.py +1 -1
  83. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_safearray.py +1 -90
  84. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_sapi.py +4 -1
  85. comtypes-1.4.10/comtypes/test/test_server.py +350 -0
  86. comtypes-1.4.10/comtypes/test/test_server_register.py +524 -0
  87. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_shelllink.py +2 -3
  88. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_showevents.py +7 -17
  89. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_storage.py +12 -6
  90. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_stream.py +16 -5
  91. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_subinterface.py +4 -2
  92. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_typeannotator.py +1 -2
  93. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_typeinfo.py +19 -7
  94. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_urlhistory.py +7 -4
  95. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_variant.py +3 -19
  96. comtypes-1.4.10/comtypes/test/test_w_getopt.py +29 -0
  97. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_win32com_interop.py +80 -36
  98. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_wmi.py +0 -3
  99. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_word.py +1 -1
  100. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/tools/codegenerator/codegenerator.py +166 -440
  101. comtypes-1.4.10/comtypes/tools/codegenerator/comments.py +79 -0
  102. comtypes-1.4.10/comtypes/tools/codegenerator/heads.py +192 -0
  103. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/tools/codegenerator/helpers.py +11 -14
  104. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/tools/codegenerator/namespaces.py +13 -5
  105. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/tools/codegenerator/packing.py +4 -4
  106. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/tools/codegenerator/typeannotator.py +19 -9
  107. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/tools/tlbparser.py +22 -23
  108. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/tools/typedesc.py +4 -8
  109. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/tools/typedesc_base.py +2 -2
  110. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/typeinfo.py +159 -63
  111. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/viewobject.py +3 -9
  112. {comtypes-1.4.8 → comtypes-1.4.10/comtypes.egg-info}/PKG-INFO +4 -3
  113. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes.egg-info/SOURCES.txt +11 -3
  114. {comtypes-1.4.8 → comtypes-1.4.10}/pyproject.toml +12 -19
  115. comtypes-1.4.8/comtypes/_comobject.py +0 -833
  116. comtypes-1.4.8/comtypes/_idl_stuff.py +0 -67
  117. comtypes-1.4.8/comtypes/client/__init__.py +0 -323
  118. comtypes-1.4.8/comtypes/server/__init__.py +0 -70
  119. comtypes-1.4.8/comtypes/server/register.py +0 -431
  120. comtypes-1.4.8/comtypes/server/w_getopt.py +0 -75
  121. comtypes-1.4.8/comtypes/test/find_memleak.py +0 -76
  122. comtypes-1.4.8/comtypes/test/test_comserver.py +0 -239
  123. comtypes-1.4.8/comtypes/test/test_dispinterface.py +0 -137
  124. comtypes-1.4.8/comtypes/test/test_propputref.py +0 -40
  125. comtypes-1.4.8/comtypes/test/test_server.py +0 -354
  126. {comtypes-1.4.8 → comtypes-1.4.10}/LICENSE.txt +0 -0
  127. {comtypes-1.4.8 → comtypes-1.4.10}/MANIFEST.in +0 -0
  128. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/_npsupport.py +0 -0
  129. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/_post_coinit/__init__.py +0 -0
  130. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/_tlib_version_checker.py +0 -0
  131. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/clear_cache.py +0 -0
  132. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/hresult.py +0 -0
  133. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/patcher.py +0 -0
  134. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/TestComServer.idl +0 -0
  135. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/TestComServer.tlb +0 -0
  136. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/TestDispServer.idl +0 -0
  137. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/TestDispServer.tlb +0 -0
  138. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/mylib.idl +0 -0
  139. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/mylib.tlb +0 -0
  140. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/mytypelib.idl +0 -0
  141. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_DISPPARAMS.py +0 -0
  142. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_dict.py +0 -0
  143. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_jscript.js +0 -0
  144. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/test_pump_events.py +0 -0
  145. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/test/urlhist.tlb +0 -0
  146. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/tools/__init__.py +0 -0
  147. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/tools/codegenerator/__init__.py +0 -0
  148. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/tools/codegenerator/modulenamer.py +0 -0
  149. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes/util.py +0 -0
  150. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes.egg-info/dependency_links.txt +0 -0
  151. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes.egg-info/entry_points.txt +0 -0
  152. {comtypes-1.4.8 → comtypes-1.4.10}/comtypes.egg-info/top_level.txt +0 -0
  153. {comtypes-1.4.8 → comtypes-1.4.10}/setup.cfg +0 -0
  154. {comtypes-1.4.8 → comtypes-1.4.10}/setup.py +0 -0
@@ -1,239 +0,0 @@
1
- import sys
2
- import unittest
3
-
4
- import comtypes.test.TestComServer
5
- from comtypes.client import CreateObject
6
- from comtypes.server.register import register # , unregister
7
- from comtypes.test import is_resource_enabled
8
- from comtypes.test.find_memleak import find_memleak
9
-
10
-
11
- def setUpModule():
12
- raise unittest.SkipTest(
13
- "This test requires the tests to be run as admin since it tries to "
14
- "register the test COM server. Is this a good idea?"
15
- )
16
-
17
- # If this test is ever NOT skipped, then this line needs to run. Keeping it here for posterity.
18
- register(comtypes.test.TestComServer.TestComServer)
19
-
20
-
21
- class TestInproc(unittest.TestCase):
22
- def create_object(self):
23
- return CreateObject(
24
- "TestComServerLib.TestComServer", clsctx=comtypes.CLSCTX_INPROC_SERVER
25
- )
26
-
27
- def _find_memleak(self, func):
28
- bytes = find_memleak(func)
29
- self.assertFalse(bytes, "Leaks %d bytes" % bytes)
30
-
31
- def test_mixedinout(self):
32
- o = self.create_object()
33
- self.assertEqual(o.MixedInOut(2, 4), (3, 5))
34
-
35
- def test_getname(self):
36
- from ctypes import pointer
37
- from comtypes import BSTR
38
-
39
- # This tests a tricky bug, introduced with this patch:
40
- # http://www.python.org/sf/1643874
41
- #
42
- # Returning a BSTR as an [out] parameter from a server
43
- # implementation must transfer the ownership to the caller.
44
- # When this is not done, the BSTR instance is SysFreeString'd
45
- # too early, and the memory is reused.
46
- obj = self.create_object()
47
- pb = pointer(BSTR())
48
- # Get the BSTR from the server:
49
- obj._ITestComServer__com__get_name(pb)
50
- # Retrieve the value, but keep the pointer to the BSTR alive:
51
- name = pb[0]
52
- # Create sme BSTR's to reuse the memory in case it has been freed:
53
- for i in range(10):
54
- BSTR("f" * len(name))
55
- # Make sure the pointer is still valid:
56
- self.assertEqual(pb[0], name)
57
-
58
- if is_resource_enabled("memleaks"):
59
-
60
- def test_get_id(self):
61
- obj = self.create_object()
62
- self._find_memleak(lambda: obj.id)
63
-
64
- def test_get_name(self):
65
- obj = self.create_object()
66
- self._find_memleak(lambda: obj.name)
67
-
68
- def test_set_name(self):
69
- obj = self.create_object()
70
-
71
- def func():
72
- obj.name = "abcde"
73
-
74
- self._find_memleak(func)
75
-
76
- def test_SetName(self):
77
- obj = self.create_object()
78
-
79
- def func():
80
- obj.SetName("abcde")
81
-
82
- self._find_memleak(func)
83
-
84
- def test_eval(self):
85
- obj = self.create_object()
86
-
87
- def func():
88
- return obj.eval("(1, 2, 3)")
89
-
90
- self.assertEqual(func(), (1, 2, 3))
91
- self._find_memleak(func)
92
-
93
- def test_get_typeinfo(self):
94
- obj = self.create_object()
95
-
96
- def func():
97
- obj.GetTypeInfo(0)
98
- obj.GetTypeInfoCount()
99
- obj.QueryInterface(comtypes.IUnknown)
100
-
101
- self._find_memleak(func)
102
-
103
-
104
- if is_resource_enabled("ui"):
105
-
106
- class TestLocalServer(TestInproc):
107
- def create_object(self):
108
- return CreateObject(
109
- "TestComServerLib.TestComServer", clsctx=comtypes.CLSCTX_LOCAL_SERVER
110
- )
111
-
112
-
113
- try:
114
- from win32com.client import Dispatch
115
- except ImportError:
116
- pass
117
- else:
118
-
119
- class TestInproc_win32com(TestInproc):
120
- def create_object(self):
121
- return Dispatch("TestComServerLib.TestComServer")
122
-
123
- # These tests make no sense with win32com, override to disable them:
124
- def test_get_typeinfo(self):
125
- pass
126
-
127
- def test_getname(self):
128
- pass
129
-
130
- def test_mixedinout(self):
131
- # Not sure about this; it raise 'Invalid Number of parameters'
132
- # Is mixed [in], [out] args not compatible with IDispatch???
133
- pass
134
-
135
- if is_resource_enabled("ui"):
136
-
137
- class TestLocalServer_win32com(TestInproc_win32com):
138
- def create_object(self):
139
- return Dispatch(
140
- "TestComServerLib.TestComServer",
141
- clsctx=comtypes.CLSCTX_LOCAL_SERVER,
142
- )
143
-
144
-
145
- import doctest
146
- import comtypes.test.test_comserver
147
-
148
-
149
- class TestCase(unittest.TestCase):
150
- def test(self):
151
- doctest.testmod(comtypes.test.test_comserver, optionflags=doctest.ELLIPSIS)
152
-
153
- # The following functions are never called, they only contain doctests:
154
-
155
- if sys.version_info >= (3, 0):
156
-
157
- def ShowEvents(self):
158
- """
159
- >>> from comtypes.client import CreateObject, ShowEvents
160
- >>>
161
- >>> o = CreateObject("TestComServerLib.TestComServer")
162
- >>> con = ShowEvents(o)
163
- # event found: ITestComServerEvents_EvalStarted
164
- # event found: ITestComServerEvents_EvalCompleted
165
- >>> result = o.eval("10. / 4")
166
- Event ITestComServerEvents_EvalStarted(None, '10. / 4')
167
- Event ITestComServerEvents_EvalCompleted(None, '10. / 4', VARIANT(vt=0x5, 2.5))
168
- >>> result
169
- 2.5
170
- >>>
171
- """
172
-
173
- else:
174
-
175
- def ShowEvents(self):
176
- """
177
- >>> from comtypes.client import CreateObject, ShowEvents
178
- >>>
179
- >>> o = CreateObject("TestComServerLib.TestComServer")
180
- >>> con = ShowEvents(o)
181
- # event found: ITestComServerEvents_EvalStarted
182
- # event found: ITestComServerEvents_EvalCompleted
183
- >>> result = o.eval("10. / 4")
184
- Event ITestComServerEvents_EvalStarted(None, u'10. / 4')
185
- Event ITestComServerEvents_EvalCompleted(None, u'10. / 4', VARIANT(vt=0x5, 2.5))
186
- >>> result
187
- 2.5
188
- >>>
189
- """
190
-
191
- # The following test, if enabled, works but the testsuit
192
- # crashes elsewhere. Is there s problem with SAFEARRAYs?
193
-
194
- if is_resource_enabled("CRASHES"):
195
-
196
- def Fails(self):
197
- """
198
- >>> from comtypes.client import CreateObject, ShowEvents
199
- >>>
200
- >>> o = CreateObject("TestComServerLib.TestComServer")
201
- >>> con = ShowEvents(o)
202
- # event found: ITestComServerEvents_EvalStarted
203
- # event found: ITestComServerEvents_EvalCompleted
204
- >>> result = o.eval("['32'] * 2")
205
- Event ITestComServerEvents_EvalStarted(None, u"['32'] * 2")
206
- Event ITestComServerEvents_EvalCompleted(None, u"['32'] * 2", VARIANT(vt=0x200c, (u'32', u'32')))
207
- >>> result
208
- (u'32', u'32')
209
- >>>
210
- """
211
-
212
- def GetEvents(self):
213
- """
214
- >>> from comtypes.client import CreateObject, GetEvents
215
- >>>
216
- >>> o = CreateObject("TestComServerLib.TestComServer")
217
- >>> class EventHandler(object):
218
- ... def EvalStarted(self, this, what):
219
- ... print("EvalStarted: %s" % what)
220
- ... return 0
221
- ... def EvalCompleted(self, this, what, result):
222
- ... print("EvalCompleted: %s = %s" % (what, result.value))
223
- ... return 0
224
- ...
225
- >>>
226
- >>> con = GetEvents(o, EventHandler())
227
- >>> o.eval("2 + 3")
228
- EvalStarted: 2 + 3
229
- EvalCompleted: 2 + 3 = 5
230
- 5
231
- >>> del con
232
- >>> o.eval("3 + 2")
233
- 5
234
- >>>
235
- """
236
-
237
-
238
- if __name__ == "__main__":
239
- unittest.main()
@@ -1,137 +0,0 @@
1
- import unittest
2
-
3
- import comtypes.test.TestDispServer
4
- from comtypes.server.register import register # , unregister
5
- from comtypes.test import is_resource_enabled
6
-
7
-
8
- def setUpModule():
9
- raise unittest.SkipTest(
10
- "This test requires the tests to be run as admin since it tries to "
11
- "register the test COM server. Is this a good idea?"
12
- )
13
-
14
- # If this test is ever NOT skipped, then this line needs to run. Keeping it here for posterity.
15
- register(comtypes.test.TestDispServer.TestDispServer)
16
-
17
-
18
- class Test(unittest.TestCase):
19
- if is_resource_enabled("pythoncom"):
20
-
21
- def test_win32com(self):
22
- # EnsureDispatch is case-sensitive
23
- from win32com.client.gencache import EnsureDispatch
24
-
25
- d = EnsureDispatch("TestDispServerLib.TestDispServer")
26
-
27
- self.assertEqual(d.eval("3.14"), 3.14)
28
- self.assertEqual(d.eval("1 + 2"), 3)
29
- self.assertEqual(d.eval("[1 + 2, 'foo', None]"), (3, "foo", None))
30
-
31
- self.assertEqual(d.eval2("3.14"), 3.14)
32
- self.assertEqual(d.eval2("1 + 2"), 3)
33
- self.assertEqual(d.eval2("[1 + 2, 'foo', None]"), (3, "foo", None))
34
-
35
- d.eval(
36
- "__import__('comtypes.client').client.CreateObject('Scripting.Dictionary')"
37
- )
38
-
39
- server_id = d.eval("id(self)")
40
- self.assertEqual(d.id, server_id)
41
-
42
- self.assertEqual(d.name, "spam, spam, spam")
43
-
44
- d.SetName("foo bar")
45
- self.assertEqual(d.name, "foo bar")
46
-
47
- d.name = "blah"
48
- self.assertEqual(d.name, "blah")
49
-
50
- def test_win32com_dyndispatch(self):
51
- # dynamic Dispatch is case-IN-sensitive
52
- from win32com.client.dynamic import Dispatch
53
-
54
- d = Dispatch("TestDispServerLib.TestDispServer")
55
-
56
- self.assertEqual(d.eval("3.14"), 3.14)
57
- self.assertEqual(d.eval("1 + 2"), 3)
58
- self.assertEqual(d.eval("[1 + 2, 'foo', None]"), (3, "foo", None))
59
-
60
- self.assertEqual(d.eval2("3.14"), 3.14)
61
- self.assertEqual(d.eval2("1 + 2"), 3)
62
- self.assertEqual(d.eval2("[1 + 2, 'foo', None]"), (3, "foo", None))
63
-
64
- d.eval(
65
- "__import__('comtypes.client').client.CreateObject('Scripting.Dictionary')"
66
- )
67
-
68
- self.assertEqual(d.EVAL("3.14"), 3.14)
69
- self.assertEqual(d.EVAL("1 + 2"), 3)
70
- self.assertEqual(d.EVAL("[1 + 2, 'foo', None]"), (3, "foo", None))
71
-
72
- self.assertEqual(d.EVAL2("3.14"), 3.14)
73
- self.assertEqual(d.EVAL2("1 + 2"), 3)
74
- self.assertEqual(d.EVAL2("[1 + 2, 'foo', None]"), (3, "foo", None))
75
-
76
- server_id = d.eval("id(self)")
77
- self.assertEqual(d.id, server_id)
78
- self.assertEqual(d.ID, server_id)
79
-
80
- self.assertEqual(d.Name, "spam, spam, spam")
81
- self.assertEqual(d.nAME, "spam, spam, spam")
82
-
83
- d.SetName("foo bar")
84
- self.assertEqual(d.Name, "foo bar")
85
-
86
- # fails. Why?
87
- # d.name = "blah"
88
- # self.assertEqual(d.Name, "blah")
89
-
90
- def test_comtypes(self):
91
- from comtypes.client import CreateObject
92
-
93
- d = CreateObject("TestDispServerLib.TestDispServer")
94
-
95
- self.assertEqual(d.eval("3.14"), 3.14)
96
- self.assertEqual(d.eval("1 + 2"), 3)
97
- self.assertEqual(d.eval("[1 + 2, 'foo', None]"), (3, "foo", None))
98
-
99
- self.assertEqual(d.eval2("3.14"), 3.14)
100
- self.assertEqual(d.eval2("1 + 2"), 3)
101
- self.assertEqual(d.eval2("[1 + 2, 'foo', None]"), (3, "foo", None))
102
-
103
- d.eval(
104
- "__import__('comtypes.client').client.CreateObject('Scripting.Dictionary')"
105
- )
106
-
107
- self.assertEqual(d.EVAL("3.14"), 3.14)
108
- self.assertEqual(d.EVAL("1 + 2"), 3)
109
- self.assertEqual(d.EVAL("[1 + 2, 'foo', None]"), (3, "foo", None))
110
-
111
- self.assertEqual(d.EVAL2("3.14"), 3.14)
112
- self.assertEqual(d.EVAL2("1 + 2"), 3)
113
- self.assertEqual(d.EVAL2("[1 + 2, 'foo', None]"), (3, "foo", None))
114
-
115
- server_id = d.eval("id(self)")
116
- self.assertEqual(d.id, server_id)
117
- self.assertEqual(d.ID, server_id)
118
-
119
- self.assertEqual(d.Name, "spam, spam, spam")
120
- self.assertEqual(d.nAME, "spam, spam, spam")
121
-
122
- d.SetName("foo bar")
123
- self.assertEqual(d.Name, "foo bar")
124
-
125
- d.name = "blah"
126
- self.assertEqual(d.Name, "blah")
127
-
128
- def test_withjscript(self):
129
- import os
130
-
131
- jscript = os.path.join(os.path.dirname(__file__), "test_jscript.js")
132
- errcode = os.system("cscript -nologo %s" % jscript)
133
- self.assertEqual(errcode, 0)
134
-
135
-
136
- if __name__ == "__main__":
137
- unittest.main()
@@ -1,40 +0,0 @@
1
- # There are also propputref tests in test_sapi.py!
2
- import unittest
3
- from comtypes.client import CreateObject
4
- from comtypes.automation import VARIANT
5
-
6
-
7
- class Test(unittest.TestCase):
8
- @unittest.skip(
9
- "Fails on creating `TestComServerLib.TestComServer`. Figure out why."
10
- )
11
- def test(self, dynamic=False):
12
- d = CreateObject("Scripting.Dictionary", dynamic=dynamic)
13
- s = CreateObject("TestComServerLib.TestComServer", dynamic=dynamic)
14
- s.name = "the value"
15
-
16
- # This calls propputref, since we assign an Object
17
- d.Item["object"] = s
18
- # This calls propput, since we assing a Value
19
- d.Item["value"] = s.name
20
-
21
- self.assertEqual(d.Item["object"], s)
22
- self.assertEqual(d.Item["object"].name, "the value")
23
- self.assertEqual(d.Item["value"], "the value")
24
-
25
- # Changing the default property of the object
26
- s.name = "foo bar"
27
- self.assertEqual(d.Item["object"], s)
28
- self.assertEqual(d.Item["object"].name, "foo bar")
29
- self.assertEqual(d.Item["value"], "the value")
30
-
31
- # This also calls propputref since we assign an Object
32
- d.Item["var"] = VARIANT(s)
33
- self.assertEqual(d.Item["var"], s)
34
-
35
- def test_dispatch(self):
36
- return self.test(dynamic=True)
37
-
38
-
39
- if __name__ == "__main__":
40
- unittest.main()