Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
CristiFati committed Feb 26, 2024
1 parent 45b0489 commit 55d3ffe
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions win32/test/test_win32gui.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# tests for win32gui
import array
import operator
import sys
import unittest

import pywin32_testutil
import pywintypes
import win32api
import win32gui


Expand Down Expand Up @@ -61,5 +64,39 @@ def test_memory_not_writable(self):
self.assertRaises(TypeError, operator.setitem, got, 0, 1)


class TestEnumWindowsFamily(unittest.TestCase):
@classmethod
def enum_callback_sle(cls, handle, data):
win32api.SetLastError(1)
return data

@classmethod
def enum_callback_exc(cls, handle, data):
raise ValueError()

@classmethod
def enum_callback(cls, handle, data):
return data

def test_enumwindows(self):
for data in (0, False):
self.assertRaises(
pywintypes.error, win32gui.EnumWindows, self.enum_callback_sle, data
)
for data in (None, 1, True):
self.assertIsNone(win32gui.EnumWindows(self.enum_callback_sle, data))
win32api.SetLastError(0)
for data in (None, -1, 0, 1, True, False):
self.assertIsNone(win32gui.EnumWindows(self.enum_callback, data))
for data in (None, True, False, 0, 1):
self.assertRaises(
ValueError, win32gui.EnumWindows, self.enum_callback_exc, data
)
if sys.version_info[:2] >= (3, 10):
for data in (2.718282, "", (), {}):
for func in (self.enum_callback, self.enum_callback_sle):
self.assertRaises(TypeError, win32gui.EnumWindows, func, data)


if __name__ == "__main__":
unittest.main()

0 comments on commit 55d3ffe

Please sign in to comment.