Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions comtypes/test/test_basic.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
##import ut
import unittest as ut
from ctypes import HRESULT, POINTER, byref
from ctypes import HRESULT, POINTER

from comtypes import GUID, STDMETHOD, IUnknown
from comtypes.typeinfo import ICreateTypeLib2, _CreateTypeLib2
from comtypes.typeinfo import SYS_WIN32, CreateTypeLib, ICreateTypeLib2

# XXX leaks references!

Expand All @@ -14,8 +13,6 @@ def method_count(interface):

class BasicTest(ut.TestCase):
def test_IUnknown(self):
from comtypes import IUnknown

self.assertEqual(method_count(IUnknown), 3)

def test_release(self):
Expand All @@ -24,8 +21,9 @@ def test_release(self):
def test_refcounts(self):
# Since all COM interfaces derive from IUnknown and have the same reference counting behavior, any interface
# — whether ICreateTypeLib2 or otherwise — could be used for this test.
p = POINTER(ICreateTypeLib2)()
_CreateTypeLib2(1, "blabla", byref(p))
p = CreateTypeLib("blabla", syskind=SYS_WIN32)
self.assertIsInstance(p, ICreateTypeLib2)
self.assertIsInstance(p, IUnknown)
# initial refcount is 2
for i in range(2, 10):
self.assertEqual(p.AddRef(), i)
Expand All @@ -35,8 +33,9 @@ def test_refcounts(self):
def test_qi(self):
# Since all COM interfaces derive from IUnknown and have the same QueryInterface behavior, any interface
# — whether ICreateTypeLib2 or otherwise — could be used for this test.
p = POINTER(ICreateTypeLib2)()
_CreateTypeLib2(1, "blabla", byref(p))
p = CreateTypeLib("blabla", syskind=SYS_WIN32)
self.assertIsInstance(p, ICreateTypeLib2)
self.assertIsInstance(p, IUnknown)
self.assertEqual(p.AddRef(), 2)
self.assertEqual(p.Release(), 1)

Expand Down Expand Up @@ -115,8 +114,6 @@ def test_identity(self):
self.assertEqual(a, b)
self.assertEqual(hash(a), hash(b))

from comtypes.typeinfo import CreateTypeLib

# we do not save the lib, so no file will be created.
# these should NOT be identical
a = CreateTypeLib("blahblah")
Expand Down
Loading