diff --git a/comtypes/test/test_basic.py b/comtypes/test/test_basic.py index d8b295bb..0c1dad59 100644 --- a/comtypes/test/test_basic.py +++ b/comtypes/test/test_basic.py @@ -1,7 +1,8 @@ ##import ut import unittest as ut -from ctypes import windll, POINTER, byref, HRESULT +from ctypes import POINTER, byref, HRESULT from comtypes import IUnknown, STDMETHOD, GUID +from comtypes.typeinfo import _CreateTypeLib2, ICreateTypeLib2 # XXX leaks references! @@ -20,8 +21,10 @@ def test_release(self): POINTER(IUnknown)() def test_refcounts(self): - p = POINTER(IUnknown)() - windll.oleaut32.CreateTypeLib2(1, "blabla", byref(p)) + # Since IUnknown behaves like an abstract class, the reference counting behavior cannot be tested directly. + # Although we use ICreateTypeLib2 here, the aim is to validate the reference counting behavior of IUnknown. + p = POINTER(ICreateTypeLib2)() + _CreateTypeLib2(1, "blabla", byref(p)) # initial refcount is 2 for i in range(2, 10): self.assertEqual(p.AddRef(), i) @@ -29,8 +32,10 @@ def test_refcounts(self): self.assertEqual(p.Release(), i) def test_qi(self): - p = POINTER(IUnknown)() - windll.oleaut32.CreateTypeLib2(1, "blabla", byref(p)) + # Since IUnknown behaves like an abstract class, the reference counting behavior cannot be tested directly. + # Although we use ICreateTypeLib2 here, the aim is to validate the reference counting behavior of IUnknown. + p = POINTER(ICreateTypeLib2)() + _CreateTypeLib2(1, "blabla", byref(p)) self.assertEqual(p.AddRef(), 2) self.assertEqual(p.Release(), 1)