diff options
| author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2025-07-28 09:52:10 +0200 |
|---|---|---|
| committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2025-10-15 11:59:13 +0200 |
| commit | 08bc8b8d6b6020e5fd307fd1a4a14baf908db6cb (patch) | |
| tree | eebe966df40630061840f339d055846491f5aee9 /sources/pyside6/tests/QtWidgets/keep_reference_test.py | |
| parent | 3369a18ff24046e21b6e505ab5399f2d69101a8d (diff) | |
Fix reference count tests (2) to pass in Python 3.14 (obscure cases)
As of 3.14, the interpreter will sometimes just borrow references and
newly created objects may have different initial reference counts.
Pick-to: 6.10 6.8
Task-number: PYSIDE-3147
Change-Id: I845460202abb95715ebf395b378b81b7790660bb
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/pyside6/tests/QtWidgets/keep_reference_test.py')
| -rw-r--r-- | sources/pyside6/tests/QtWidgets/keep_reference_test.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/sources/pyside6/tests/QtWidgets/keep_reference_test.py b/sources/pyside6/tests/QtWidgets/keep_reference_test.py index f93770aa0..e9b962279 100644 --- a/sources/pyside6/tests/QtWidgets/keep_reference_test.py +++ b/sources/pyside6/tests/QtWidgets/keep_reference_test.py @@ -54,6 +54,8 @@ class KeepReferenceTest(UsesQApplication): refcount1 = sys.getrefcount(model1) view1 = QTableView() view1.setModel(model1) + if sys.version_info >= (3, 14): + refcount1 += 1 self.assertEqual(sys.getrefcount(view1.model()), refcount1 + 1) view2 = QTableView() @@ -69,9 +71,10 @@ class KeepReferenceTest(UsesQApplication): '''Tests reference count of model object referred by deceased view object.''' model = TestModel() refcount1 = sys.getrefcount(model) + delta = 2 if sys.version_info >= (3, 14) else 1 view = QTableView() view.setModel(model) - self.assertEqual(sys.getrefcount(view.model()), refcount1 + 1) + self.assertEqual(sys.getrefcount(view.model()), refcount1 + delta) del view self.assertEqual(sys.getrefcount(model), refcount1) |
