Skip to content

Commit

Permalink
[test\test_basic.py] Use WinDLL instead of windll
Browse files Browse the repository at this point in the history
IUnknown to ICreateTypeLib2 because CreateTypeLib2 doesn't take IUnknown as a parameter
  • Loading branch information
moi15moi committed Jan 25, 2025
1 parent 8977aa4 commit c8d1c7c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions comtypes/test/test_basic.py
Original file line number Diff line number Diff line change
@@ -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!

Expand All @@ -20,17 +21,17 @@ def test_release(self):
POINTER(IUnknown)()

def test_refcounts(self):
p = POINTER(IUnknown)()
windll.oleaut32.CreateTypeLib2(1, "blabla", byref(p))
p = POINTER(ICreateTypeLib2)()
_CreateTypeLib2(1, "blabla", byref(p))
# initial refcount is 2
for i in range(2, 10):
self.assertEqual(p.AddRef(), i)
for i in range(8, 0, -1):
self.assertEqual(p.Release(), i)

def test_qi(self):
p = POINTER(IUnknown)()
windll.oleaut32.CreateTypeLib2(1, "blabla", byref(p))
p = POINTER(ICreateTypeLib2)()
_CreateTypeLib2(1, "blabla", byref(p))
self.assertEqual(p.AddRef(), 2)
self.assertEqual(p.Release(), 1)

Expand Down

0 comments on commit c8d1c7c

Please sign in to comment.