Funktionierender Prototyp des Serious Games zur Vermittlung von Wissen zu Software-Engineering-Arbeitsmodellen.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_pycomtest.py 5.0KB

1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. # This is part of the Python test suite.
  2. # The object is registered when you first run the test suite.
  3. # (and hopefully unregistered once done ;-)
  4. import pythoncom
  5. import winerror
  6. # Ensure the vtables in the tlb are known.
  7. from win32com import universal
  8. from win32com.client import constants, gencache
  9. from win32com.server.exception import COMException
  10. from win32com.server.util import wrap
  11. pythoncom.__future_currency__ = True
  12. # We use the constants from the module, so must insist on a gencache.
  13. # Otherwise, use of gencache is not necessary (tho still advised)
  14. gencache.EnsureModule("{6BCDCB60-5605-11D0-AE5F-CADD4C000000}", 0, 1, 1)
  15. class PyCOMTest:
  16. _typelib_guid_ = "{6BCDCB60-5605-11D0-AE5F-CADD4C000000}"
  17. _typelib_version = 1, 0
  18. _com_interfaces_ = ["IPyCOMTest"]
  19. _reg_clsid_ = "{e743d9cd-cb03-4b04-b516-11d3a81c1597}"
  20. _reg_progid_ = "Python.Test.PyCOMTest"
  21. def DoubleString(self, str):
  22. return str * 2
  23. def DoubleInOutString(self, str):
  24. return str * 2
  25. def Fire(self, nID):
  26. raise COMException(hresult=winerror.E_NOTIMPL)
  27. def GetLastVarArgs(self):
  28. raise COMException(hresult=winerror.E_NOTIMPL)
  29. def GetMultipleInterfaces(self, outinterface1, outinterface2):
  30. raise COMException(hresult=winerror.E_NOTIMPL)
  31. def GetSafeArrays(self, attrs, attrs2, ints):
  32. raise COMException(hresult=winerror.E_NOTIMPL)
  33. def GetSetDispatch(self, indisp):
  34. raise COMException(hresult=winerror.E_NOTIMPL)
  35. # Result is of type IPyCOMTest
  36. def GetSetInterface(self, ininterface):
  37. return wrap(self)
  38. def GetSetVariant(self, indisp):
  39. return indisp
  40. def TestByRefVariant(self, v):
  41. return v * 2
  42. def TestByRefString(self, v):
  43. return v * 2
  44. # Result is of type IPyCOMTest
  45. def GetSetInterfaceArray(self, ininterface):
  46. raise COMException(hresult=winerror.E_NOTIMPL)
  47. def GetSetUnknown(self, inunk):
  48. raise COMException(hresult=winerror.E_NOTIMPL)
  49. # Result is of type ISimpleCounter
  50. def GetSimpleCounter(self):
  51. raise COMException(hresult=winerror.E_NOTIMPL)
  52. def GetSimpleSafeArray(self, ints):
  53. raise COMException(hresult=winerror.E_NOTIMPL)
  54. def GetStruct(self):
  55. raise COMException(hresult=winerror.E_NOTIMPL)
  56. def SetIntSafeArray(self, ints):
  57. return len(ints)
  58. def SetLongLongSafeArray(self, ints):
  59. return len(ints)
  60. def SetULongLongSafeArray(self, ints):
  61. return len(ints)
  62. def SetBinSafeArray(self, buf):
  63. return len(buf)
  64. def SetVarArgs(self, *args):
  65. raise COMException(hresult=winerror.E_NOTIMPL)
  66. def SetVariantSafeArray(self, vars):
  67. raise COMException(hresult=winerror.E_NOTIMPL)
  68. def Start(self):
  69. raise COMException(hresult=winerror.E_NOTIMPL)
  70. def Stop(self, nID):
  71. raise COMException(hresult=winerror.E_NOTIMPL)
  72. def StopAll(self):
  73. raise COMException(hresult=winerror.E_NOTIMPL)
  74. def TakeByRefDispatch(self, inout):
  75. raise COMException(hresult=winerror.E_NOTIMPL)
  76. def TakeByRefTypedDispatch(self, inout):
  77. raise COMException(hresult=winerror.E_NOTIMPL)
  78. def Test(self, key, inval):
  79. return not inval
  80. def Test2(self, inval):
  81. return inval
  82. def Test3(self, inval):
  83. raise COMException(hresult=winerror.E_NOTIMPL)
  84. def Test4(self, inval):
  85. raise COMException(hresult=winerror.E_NOTIMPL)
  86. def Test5(self, inout):
  87. if inout == constants.TestAttr1:
  88. return constants.TestAttr1_1
  89. elif inout == constants.TestAttr1_1:
  90. return constants.TestAttr1
  91. else:
  92. return -1
  93. def Test6(self, inval):
  94. return inval
  95. def TestInOut(self, fval, bval, lval):
  96. return winerror.S_OK, fval * 2, not bval, lval * 2
  97. def TestOptionals(self, strArg="def", sval=0, lval=1, dval=3.1400001049041748):
  98. raise COMException(hresult=winerror.E_NOTIMPL)
  99. def TestOptionals2(self, dval, strval="", sval=1):
  100. raise COMException(hresult=winerror.E_NOTIMPL)
  101. def CheckVariantSafeArray(self, data):
  102. return 1
  103. def LongProp(self):
  104. return self.longval
  105. def SetLongProp(self, val):
  106. self.longval = val
  107. def ULongProp(self):
  108. return self.ulongval
  109. def SetULongProp(self, val):
  110. self.ulongval = val
  111. def IntProp(self):
  112. return self.intval
  113. def SetIntProp(self, val):
  114. self.intval = val
  115. class PyCOMTestMI(PyCOMTest):
  116. _typelib_guid_ = "{6BCDCB60-5605-11D0-AE5F-CADD4C000000}"
  117. _typelib_version = 1, 0
  118. # Interfaces with a interface name, a real IID, and an IID as a string
  119. _com_interfaces_ = [
  120. "IPyCOMTest",
  121. pythoncom.IID_IStream,
  122. str(pythoncom.IID_IStorage),
  123. ]
  124. _reg_clsid_ = "{F506E9A1-FB46-4238-A597-FA4EB69787CA}"
  125. _reg_progid_ = "Python.Test.PyCOMTestMI"
  126. if __name__ == "__main__":
  127. import win32com.server.register
  128. win32com.server.register.UseCommandLine(PyCOMTest)
  129. win32com.server.register.UseCommandLine(PyCOMTestMI)