diff options
author | Christian Tismer <tismer@stackless.com> | 2021-10-25 19:22:33 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-10-27 14:28:53 +0000 |
commit | f02623461d6f8a0d9803e49d3f8928bf78ad7d6d (patch) | |
tree | 25a5f456e1243fb154568856603428b6a8f6d257 /sources/pyside6/tests/QtGui | |
parent | 587b6d15411debf979f2e4e06372e596409eadda (diff) |
PyPySide: fix quite a few tests using del or __del__
In PyPy, the __del__ method is only triggered
reliably by calling gc.collect()
Also, the del statement does a deletion from the namespace,
but the real deletion happens when gc.collent() is called.
This was applied to all tests which use del, regardless if
it has a visible effect on PyPy or not. It turned out to
save more 8 errors, which is great.
Task-number: PYSIDE-535
Change-Id: I6a58d90629c9eafec7307c17f021251113b3c7f2
Reviewed-by: Christian Tismer <tismer@stackless.com>
(cherry picked from commit c7c789b1822fe0b2e77e66e5c1a66a16b3c3c405)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'sources/pyside6/tests/QtGui')
5 files changed, 23 insertions, 4 deletions
diff --git a/sources/pyside6/tests/QtGui/bug_652.py b/sources/pyside6/tests/QtGui/bug_652.py index 5feecd64a..e6b777785 100644 --- a/sources/pyside6/tests/QtGui/bug_652.py +++ b/sources/pyside6/tests/QtGui/bug_652.py @@ -26,6 +26,7 @@ ## ############################################################################# +import gc import os import sys import unittest @@ -59,6 +60,8 @@ class TestBug652(unittest.TestCase): self.assertEqual(tc.block().userData().getMyNiceData(), heyHo) del tc + # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion + gc.collect() tc = QTextCursor(td) blk = tc.block() self.assertEqual(type(blk.userData()), MyData) diff --git a/sources/pyside6/tests/QtGui/float_to_int_implicit_conversion_test.py b/sources/pyside6/tests/QtGui/float_to_int_implicit_conversion_test.py index 5383f79d7..3520eac4a 100644 --- a/sources/pyside6/tests/QtGui/float_to_int_implicit_conversion_test.py +++ b/sources/pyside6/tests/QtGui/float_to_int_implicit_conversion_test.py @@ -1,6 +1,6 @@ ############################################################################# ## -## Copyright (C) 2016 The Qt Company Ltd. +## Copyright (C) 2021 The Qt Company Ltd. ## Contact: https://www.qt.io/licensing/ ## ## This file is part of the test suite of Qt for Python. @@ -28,6 +28,7 @@ '''Test cases for QImage''' +import gc import os import sys import unittest @@ -55,6 +56,8 @@ class SetPixelFloat(UsesQApplication): # Release resources del self.color del self.image + # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion + gc.collect() super(SetPixelFloat, self).tearDown() def testFloat(self): diff --git a/sources/pyside6/tests/QtGui/qcolor_test.py b/sources/pyside6/tests/QtGui/qcolor_test.py index 85ba2de2d..59d6c1a53 100644 --- a/sources/pyside6/tests/QtGui/qcolor_test.py +++ b/sources/pyside6/tests/QtGui/qcolor_test.py @@ -1,6 +1,6 @@ ############################################################################# ## -## Copyright (C) 2016 The Qt Company Ltd. +## Copyright (C) 2021 The Qt Company Ltd. ## Contact: https://www.qt.io/licensing/ ## ## This file is part of the test suite of Qt for Python. @@ -27,6 +27,7 @@ ############################################################################# import colorsys +import gc import os import sys import unittest @@ -101,6 +102,8 @@ class QColorCopy(unittest.TestCase): self.assertTrue(original is not copy) self.assertEqual(original, copy) del original + # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion + gc.collect() self.assertEqual(copy, QColor(0, 0, 255)) def testEmptyCopy(self): @@ -111,6 +114,8 @@ class QColorCopy(unittest.TestCase): self.assertTrue(original is not copy) self.assertEqual(original, copy) del original + # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion + gc.collect() self.assertEqual(copy, QColor()) diff --git a/sources/pyside6/tests/QtGui/qfontmetrics_test.py b/sources/pyside6/tests/QtGui/qfontmetrics_test.py index 9f3099acd..45245b7bd 100644 --- a/sources/pyside6/tests/QtGui/qfontmetrics_test.py +++ b/sources/pyside6/tests/QtGui/qfontmetrics_test.py @@ -1,6 +1,6 @@ ############################################################################# ## -## Copyright (C) 2016 The Qt Company Ltd. +## Copyright (C) 2021 The Qt Company Ltd. ## Contact: https://www.qt.io/licensing/ ## ## This file is part of the test suite of Qt for Python. @@ -29,6 +29,7 @@ '''Tests for inject codes and modifications on QFontMetrics and QFontMetricsF''' +import gc import os import sys import unittest @@ -54,6 +55,8 @@ class QFontMetricsTest(UsesQApplication): def tearDown(self): del self.metrics del self.font + # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion + gc.collect() super(QFontMetricsTest, self).tearDown() @@ -156,6 +159,8 @@ class QFontMetricsFTest(UsesQApplication): def tearDown(self): del self.metrics del self.font + # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion + gc.collect() super(QFontMetricsFTest, self).tearDown() diff --git a/sources/pyside6/tests/QtGui/qpainter_test.py b/sources/pyside6/tests/QtGui/qpainter_test.py index a099e9df8..489a0e39b 100644 --- a/sources/pyside6/tests/QtGui/qpainter_test.py +++ b/sources/pyside6/tests/QtGui/qpainter_test.py @@ -1,6 +1,6 @@ ############################################################################# ## -## Copyright (C) 2016 The Qt Company Ltd. +## Copyright (C) 2021 The Qt Company Ltd. ## Contact: https://www.qt.io/licensing/ ## ## This file is part of the test suite of Qt for Python. @@ -26,6 +26,7 @@ ## ############################################################################# +import gc import os import sys import unittest @@ -58,6 +59,8 @@ class QPainterDrawText(UsesQGuiApplication): del self.text self.painter.end() del self.painter + # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion + gc.collect() super(QPainterDrawText, self).tearDown() def testDrawText(self): |