LibreOffice Module unotest (master) 1
unittest.py
Go to the documentation of this file.
1# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
2#
3# This file is part of the LibreOffice project.
4#
5# This Source Code Form is subject to the terms of the Mozilla Public
6# License, v. 2.0. If a copy of the MPL was not distributed with this
7# file, You can obtain one at http://mozilla.org/MPL/2.0/.
8#
9
10import gc
11import pyuno
12import unittest
13
14class LoTestResult(unittest.TextTestResult):
15 def stopTestRun(self):
16 # HACK calling gc.collect() to get rid of as many still existing UNO proxies to
17 # SwXTextDocument and friends as possible; those C++ classes' dtors call
18 # Application::GetSolarMutex via sw::UnoImplPtrDeleter, so the dtors must be called before
19 # DeInitVCL in the call to pyuno.private_deinitTestEnvironment(); any remaining proxies
20 # that are still referenced (UnoInProcess' self.xDoc in
21 # unotest/source/python/org/libreoffice/unotest.py, or per-class variables in the various
22 # PythonTests) need to be individually released (each marked as "HACK" in the code):
23 gc.collect()
24 pyuno.private_deinitTestEnvironment()
25
26if __name__ == '__main__':
27 unittest.main(module=None, testRunner=unittest.TextTestRunner(resultclass=LoTestResult))
28
29# vim: set shiftwidth=4 softtabstop=4 expandtab: