aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/tests/QtCore/qobject_event_filter_test.py
diff options
context:
space:
mode:
Diffstat (limited to 'sources/pyside6/tests/QtCore/qobject_event_filter_test.py')
-rw-r--r--sources/pyside6/tests/QtCore/qobject_event_filter_test.py24
1 files changed, 20 insertions, 4 deletions
diff --git a/sources/pyside6/tests/QtCore/qobject_event_filter_test.py b/sources/pyside6/tests/QtCore/qobject_event_filter_test.py
index a2870221d..ab7a1b6ad 100644
--- a/sources/pyside6/tests/QtCore/qobject_event_filter_test.py
+++ b/sources/pyside6/tests/QtCore/qobject_event_filter_test.py
@@ -16,7 +16,7 @@ init_test_paths(False)
from PySide6.QtCore import QObject, QTimerEvent
-from helper.usesqcoreapplication import UsesQCoreApplication
+from helper.usesqapplication import UsesQApplication
class FilterObject(QObject):
@@ -63,14 +63,25 @@ class FilteredObject(QObject):
self.app.quit()
-class TestQObjectEventFilterPython(UsesQCoreApplication):
+class PolymorphicIdFilterObject(QObject):
+ """PYSIDE-2675: Check whether QChildEvent.added() is accessible via PolymorphicId"""
+ def __init__(self, parent=None):
+ super().__init__(parent)
+ self.added = False
+
+ def event(self, event):
+ self.added = event.added()
+ return False
+
+
+class TestQObjectEventFilterPython(UsesQApplication):
'''QObject.eventFilter - Reimplemented in python
Filters 5 TimerEvents and then bypasses the other events to the
timerEvent method. After 5 runs, the timerEvent method will ask
the core application to exit'''
def setUp(self):
# Acquire resources
- UsesQCoreApplication.setUp(self)
+ UsesQApplication.setUp(self)
self.obj_filter = FilterObject(event_type=QTimerEvent)
def tearDown(self):
@@ -78,7 +89,7 @@ class TestQObjectEventFilterPython(UsesQCoreApplication):
del self.obj_filter
# PYSIDE-535: Need to collect garbage in PyPy to trigger deletion
gc.collect()
- UsesQCoreApplication.tearDown(self)
+ UsesQApplication.tearDown(self)
def testEventFilter(self):
# QObject.eventFilter reimplemented in python
@@ -93,6 +104,11 @@ class TestQObjectEventFilterPython(UsesQCoreApplication):
self.assertEqual(filtered.times_called, 5)
self.assertEqual(self.obj_filter.events_handled, 5)
+ def testPolymorphicId(self):
+ testObject = PolymorphicIdFilterObject()
+ t2 = QObject(testObject) # noqa: F841
+ self.assertTrue(testObject.added)
+
@unittest.skipUnless(hasattr(sys, "getrefcount"), f"{sys.implementation.name} has no refcount")
def testInstallEventFilterRefCountAfterDelete(self):
'''Bug 910 - installEventFilter() increments reference count on target object