From f2aca4e038888b32650027b5c7d67eda69a8fd48 Mon Sep 17 00:00:00 2001 From: Noel Date: Wed, 28 Oct 2020 13:09:52 +0200 Subject: [PATCH] python test shutdown robustness so when a test fails, we don't get spurious additional stacktraces Change-Id: Id2885be9ca628fc25a55f90f6c5c1b50f887a37a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104928 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sw/qa/python/xcontrolshape.py | 3 ++- unotest/source/python/org/libreoffice/unotest.py | 11 ++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/sw/qa/python/xcontrolshape.py b/sw/qa/python/xcontrolshape.py index cfbcedba73c9..336a6d3449c0 100644 --- a/sw/qa/python/xcontrolshape.py +++ b/sw/qa/python/xcontrolshape.py @@ -23,7 +23,8 @@ class TestXControlShape(unittest.TestCase): @classmethod def tearDownClass(cls): - cls._uno.tearDown() + if cls._uno: + cls._uno.tearDown() def test_getAndSetControlShape(self): xDoc = self.__class__._uno.openDocFromTDOC("xcontrolshape.odt") diff --git a/unotest/source/python/org/libreoffice/unotest.py b/unotest/source/python/org/libreoffice/unotest.py index 8b421e167c0c..e27f9e145de4 100644 --- a/unotest/source/python/org/libreoffice/unotest.py +++ b/unotest/source/python/org/libreoffice/unotest.py @@ -243,11 +243,12 @@ class UnoInProcess: assert(self.xContext) def tearDown(self): if hasattr(self, 'xDoc'): - self.xDoc.close(True) - # HACK in case self.xDoc holds a UNO proxy to an SwXTextDocument (whose dtor calls - # Application::GetSolarMutex via sw::UnoImplPtrDeleter), which would potentially only be - # garbage-collected after VCL has already been deinitialized: - self.xDoc = None + if self.xDoc: + self.xDoc.close(True) + # HACK in case self.xDoc holds a UNO proxy to an SwXTextDocument (whose dtor calls + # Application::GetSolarMutex via sw::UnoImplPtrDeleter), which would potentially only be + # garbage-collected after VCL has already been deinitialized: + self.xDoc = None def simpleInvoke(connection, test): try: