Skip to content

Commit

Permalink
Remove is_resource_enabled and requires from tests. (#686)
Browse files Browse the repository at this point in the history
* Remove `is_resource_enabled` from `test_comserver`.

* Remove `requires` from `test_BSTR`.

* Remove `requires` from `test_createwrappers`.

* Remove `requires` from `test_ie`.

* Remove `requires` from `test_win32com_interop`.

* Remove `requires` from `test_outparam`.

* Remove `requires` from `test_wmi`.
  • Loading branch information
junkmd authored Dec 7, 2024
1 parent 7295d40 commit c19790c
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 58 deletions.
9 changes: 3 additions & 6 deletions comtypes/test/test_BSTR.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import unittest, os
from ctypes import *
from comtypes import BSTR
from comtypes.test import requires

##requires("memleaks")
import unittest
from ctypes import WINFUNCTYPE, c_uint, c_void_p, oledll, windll

from comtypes import BSTR
from comtypes.test.find_memleak import find_memleak


Expand Down
48 changes: 21 additions & 27 deletions comtypes/test/test_comserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from comtypes import BSTR
from comtypes.client import CreateObject
from comtypes.server.register import register, unregister
from comtypes.test import is_resource_enabled
from comtypes.test.find_memleak import find_memleak


Expand Down Expand Up @@ -145,15 +144,12 @@ def test_mixedinout(self):
# Is mixed [in], [out] args not compatible with IDispatch???
pass

if is_resource_enabled("ui"):

@unittest.skip("This depends on 'pywin32'.")
class TestLocalServer_win32com(TestInproc_win32com):
def create_object(self):
return Dispatch(
"TestComServerLib.TestComServer",
clsctx=comtypes.CLSCTX_LOCAL_SERVER,
)
@unittest.skip("This depends on 'pywin32'.")
class TestLocalServer_win32com(TestInproc_win32com):
def create_object(self):
return Dispatch(
"TestComServerLib.TestComServer", clsctx=comtypes.CLSCTX_LOCAL_SERVER
)


class TestEvents(unittest.TestCase):
Expand Down Expand Up @@ -187,23 +183,21 @@ def ShowEventsFloat(self):
# # The following test, if enabled, works but the testsuit
# # crashes elsewhere. Is there s problem with SAFEARRAYs?

# if is_resource_enabled("CRASHES"):

# def Fails(self):
# """
# >>> from comtypes.client import CreateObject, ShowEvents
# >>>
# >>> o = CreateObject("TestComServerLib.TestComServer")
# >>> con = ShowEvents(o)
# # event found: ITestComServerEvents_EvalStarted
# # event found: ITestComServerEvents_EvalCompleted
# >>> result = o.eval("['32'] * 2")
# Event ITestComServerEvents_EvalStarted(None, u"['32'] * 2")
# Event ITestComServerEvents_EvalCompleted(None, u"['32'] * 2", VARIANT(vt=0x200c, (u'32', u'32')))
# >>> result
# (u'32', u'32')
# >>>
# """
# def Fails(self):
# """
# >>> from comtypes.client import CreateObject, ShowEvents
# >>>
# >>> o = CreateObject("TestComServerLib.TestComServer")
# >>> con = ShowEvents(o)
# # event found: ITestComServerEvents_EvalStarted
# # event found: ITestComServerEvents_EvalCompleted
# >>> result = o.eval("['32'] * 2")
# Event ITestComServerEvents_EvalStarted(None, u"['32'] * 2")
# Event ITestComServerEvents_EvalCompleted(None, u"['32'] * 2", VARIANT(vt=0x200c, (u'32', u'32')))
# >>> result
# (u'32', u'32')
# >>>
# """

def GetEvents(self):
"""
Expand Down
2 changes: 0 additions & 2 deletions comtypes/test/test_createwrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ def setUpModule():
)


# requires("typelibs")

# filter warnings about interfaces without a base interface; they will
# be skipped in the code generation.
warnings.filterwarnings(
Expand Down
7 changes: 2 additions & 5 deletions comtypes/test/test_ie.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import unittest as ut
from ctypes import *
from ctypes import Structure, c_long, c_uint, c_ulong

import comtypes.test
from comtypes.client import CreateObject, GetEvents

comtypes.test.requires("ui")


def setUpModule():
raise ut.SkipTest(
Expand Down Expand Up @@ -61,7 +58,7 @@ class MSG(Structure):


def PumpWaitingMessages():
from ctypes import windll, byref
from ctypes import byref, windll

user32 = windll.user32
msg = MSG()
Expand Down
27 changes: 17 additions & 10 deletions comtypes/test/test_outparam.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
import sys
import unittest
from ctypes import *
from ctypes import (
POINTER,
byref,
c_int,
c_ulong,
c_void_p,
c_wchar,
c_wchar_p,
cast,
memmove,
oledll,
sizeof,
windll,
wstring_at,
)
from unittest.mock import patch

import comtypes.test
from comtypes import COMMETHOD, GUID, IUnknown

comtypes.test.requires("devel")

from comtypes import IUnknown, GUID, COMMETHOD

if sys.version_info >= (3, 0):
text_type = str
else:
text_type = unicode
text_type = str


class IMalloc(IUnknown):
Expand Down
7 changes: 2 additions & 5 deletions comtypes/test/test_win32com_interop.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import unittest

from ctypes import PyDLL, py_object, c_void_p, byref, POINTER
from ctypes import POINTER, PyDLL, byref, c_void_p, py_object
from ctypes.wintypes import BOOL

from comtypes import IUnknown
from comtypes.client import CreateObject
from comtypes.automation import IDispatch
from comtypes.test import requires
from comtypes.client import CreateObject

requires("pythoncom")
try:
import pythoncom
import win32com.client
Expand Down
3 changes: 0 additions & 3 deletions comtypes/test/test_wmi.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import unittest as ut

from comtypes.client import CoGetObject
from comtypes.test import requires

requires("time")


# WMI has dual interfaces.
Expand Down

0 comments on commit c19790c

Please sign in to comment.