Skip to content

Commit

Permalink
poc
Browse files Browse the repository at this point in the history
  • Loading branch information
junkmd committed Jan 27, 2025
1 parent 547e736 commit 5a4cd34
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion comtypes/test/test_comserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
from ctypes import pointer
from typing import Any

import comtypes.server
import comtypes.test.TestComServer
from comtypes import BSTR
from comtypes.automation import VARIANT, _midlSAFEARRAY
from comtypes.client import CreateObject
from comtypes.client import CreateObject, GetActiveObject
from comtypes.server.register import register, unregister
from comtypes.test.find_memleak import find_memleak

Expand Down Expand Up @@ -108,6 +109,23 @@ def func():

self._find_memleak(func)

def test_activeobj(self):
from comtypes.gen import TestComServerLib

c = comtypes.test.TestComServer.TestComServer()
with self.assertRaises(OSError): # type: ignore
GetActiveObject(comtypes.test.TestComServer.TestComServer)
handle = comtypes.server.RegisterActiveObject(c)
obj = GetActiveObject(
comtypes.test.TestComServer.TestComServer,
interface=TestComServerLib.ITestComServer,
)
self.assertIsInstance(obj, TestComServerLib.ITestComServer) # type: ignore
self.assertEqual(obj.MixedInOut(2, 4), (3, 5)) # type: ignore
comtypes.server.RevokeActiveObject(handle)
with self.assertRaises(OSError): # type: ignore
GetActiveObject(comtypes.test.TestComServer.TestComServer)


class TestInproc(BaseServerTest, unittest.TestCase):
def create_object(self):
Expand Down

0 comments on commit 5a4cd34

Please sign in to comment.