From d1868d70f0f5ae38efd532911c5a7e28ebd02752 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 28 Jan 2020 11:31:37 +0100 Subject: Prospective fix for flaky smart_pointer_test.py The test has been observed to fail apparently since the result was not collected. Traceback (most recent call last) File "sources/shiboken2/tests/smartbinding/smart_pointer_test.py", line 82, in testObjSmartPointer self.assertEqual(integerCount(), 1) AssertionError 2 != 1 File "sources/shiboken2/tests/smartbinding/smart_pointer_test.py", line 154, in testSmartPointersWithNamespace self.assertEqual(integerCount(), 2) AssertionError 3 != 2 Enforce a garbage collection to ensure the object is deleted. Task-number: PYSIDE-454 Change-Id: I85baa059319a5286f94a5607c4de32bfc50ae0e0 Reviewed-by: Christian Tismer --- build_history/blacklist.txt | 4 +--- sources/shiboken2/tests/smartbinding/smart_pointer_test.py | 7 +++++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/build_history/blacklist.txt b/build_history/blacklist.txt index adcf5206d..33c1ba016 100644 --- a/build_history/blacklist.txt +++ b/build_history/blacklist.txt @@ -68,9 +68,7 @@ [QtQml::qquickitem_grabToImage] darwin [smart::smart_pointer] - win32 - linux - darwin + py2 # PYSIDE-474 [QtWebEngineWidgets::pyside-474-qtwebengineview] py2 diff --git a/sources/shiboken2/tests/smartbinding/smart_pointer_test.py b/sources/shiboken2/tests/smartbinding/smart_pointer_test.py index e1883c7cc..b26a3dcbc 100644 --- a/sources/shiboken2/tests/smartbinding/smart_pointer_test.py +++ b/sources/shiboken2/tests/smartbinding/smart_pointer_test.py @@ -29,6 +29,10 @@ ## ############################################################################# +from __future__ import print_function + +import gc +import sys import unittest from copy import copy from smart import Obj, Registry, Integer @@ -79,6 +83,9 @@ class SmartPointerTests(unittest.TestCase): result = ptrToObj.takeInteger(ptrToObj.m_internalInteger) self.assertEqual(integerCount(), 2) result = None + if integerCount() > 1: + gc.collect() + print('Running garbage collector for reference test', file=sys.stderr) self.assertEqual(integerCount(), 1) # Make a copy of the shared pointer, object count should not change. -- cgit v1.2.3