diff options
| author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2025-07-28 09:48:57 +0200 |
|---|---|---|
| committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2025-08-05 16:31:46 +0200 |
| commit | 119ef9f7af2c4da98dd678f7d5d1a88f594cf95d (patch) | |
| tree | 794eea8bef71766e6c8ee5cc3dbb213697d0d746 /sources/pyside6/tests/QtWidgets/qlayout_test.py | |
| parent | 687d8ea785ad11c30db2d3542c6ba11e41c57851 (diff) | |
Fix reference count tests (1) to pass in Python 3.14 (simple cases)
As of 3.14, the interpreter will sometimes just borrow references and
newly created objects may have different initial reference counts. Fix
the test cases where a base ref count of a new object is compared
against.
Pick-to: 6.9 6.8
Task-number: PYSIDE-3147
Change-Id: I698be2309362fc65f6727971a5cec4fc4f40cf2e
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/pyside6/tests/QtWidgets/qlayout_test.py')
| -rw-r--r-- | sources/pyside6/tests/QtWidgets/qlayout_test.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/sources/pyside6/tests/QtWidgets/qlayout_test.py b/sources/pyside6/tests/QtWidgets/qlayout_test.py index 26449c346..c12126b1c 100644 --- a/sources/pyside6/tests/QtWidgets/qlayout_test.py +++ b/sources/pyside6/tests/QtWidgets/qlayout_test.py @@ -69,39 +69,41 @@ class QLayoutTest(UsesQApplication): @unittest.skipUnless(hasattr(sys, "getrefcount"), f"{sys.implementation.name} has no refcount") def testOwnershipTransfer(self): b = QPushButton("teste") + base_ref_count = sys.getrefcount(b) layout = MyLayout() layout.addWidget(b) - self.assertEqual(sys.getrefcount(b), 2) + self.assertEqual(sys.getrefcount(b), base_ref_count) w = QWidget() # transfer ref w.setLayout(layout) - self.assertEqual(sys.getrefcount(b), 3) + self.assertEqual(sys.getrefcount(b), base_ref_count + 1) @unittest.skipUnless(hasattr(sys, "getrefcount"), f"{sys.implementation.name} has no refcount") def testReferenceTransfer(self): b = QPushButton("teste") + base_ref_count = sys.getrefcount(b) layout = QHBoxLayout() # keep ref layout.addWidget(b) - self.assertEqual(sys.getrefcount(b), 3) + self.assertEqual(sys.getrefcount(b), base_ref_count + 1) w = QWidget() # transfer ref w.setLayout(layout) - self.assertEqual(sys.getrefcount(b), 3) + self.assertEqual(sys.getrefcount(b), base_ref_count + 1) # release ref del w - self.assertEqual(sys.getrefcount(b), 2) + self.assertEqual(sys.getrefcount(b), base_ref_count) def testMissingFunctions(self): w = QWidget() |
