summaryrefslogtreecommitdiff
path: root/unotest/source/python/org/libreoffice/unotest.py
AgeCommit message (Collapse)AuthorFilesLines
2023-12-27tdf#158803 Fix issues detected by pyflakesChenxiong Qi1-5/+1
Change-Id: Iaa329dff61db894e7d5fecd840e785a53a48b26f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160889 Tested-by: Jenkins Reviewed-by: Hossein <hossein@libreoffice.org>
2020-10-29python test shutdown robustnessNoel1-5/+6
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 <noel.grandin@collabora.co.uk>
2020-04-09pyuno,*: kill Python 2 support with fireMichael Stahl1-2/+0
Python 2 support was retained for use with --enable-python=system on RHEL7 and SLES. The time has arrived to remove it. Some .py files that were imported from third parties are not changed to enable easier replacement with updated versions if necessary. solenv/gdb should continue to support Python 2. bin/get-bugzilla-attachments-by-mimetype requires Python 2 to access Launchpad. Change-Id: I26414ae8e9f8402c90336af82020135685694217 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91697 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de>
2019-10-02WTF "WTF 255 return value?"Stephan Bergmann1-4/+2
0e68bac85293e2d60fa6db3e46de8b74ab5d502b "set up python unit test infrastructure" had introduced unotest/source/python/org/libreoffice/unotest.py with the comment and commented-out code. It claims it has extraced "boostraping code from convwatch.py to unotest.py", but I can't find a trace in the git history of a prior incarnation of that comment and commented-out code. It is unclear what problem exactly the commenting-out of the check was supposed to address. So put the check in place and see what, if anything, breaks. (The commented-out return appears to be truly unnecessary, and has been removed completely.) Change-Id: Ie2108d70fbe076cd0832bd23bfb29fc60eedffef Reviewed-on: https://gerrit.libreoffice.org/80029 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-09-07DeInitVCL in PythonTestStephan Bergmann1-1/+6
After b9757f5cfdb62b24e79eeb4c0ef0c8b98056cecf "loplugin:useuniqueptr in vcl/svdata" ASan/UBSan builds started to fail (like <https://ci.libreoffice.org//job/lo_ubsan/1025/>) at the end of PythonTest_dbaccess_python (and probably other PythonTests), when during exit the static utl::ConfigManager instance already happens to be destroyed by the time the static ImplSVData's mpSettingsConfigItem is destroyed (which would normally be cleared during DeInitVCL, if PythonTests would call that, and which in the past had thus simply been leaked in PythonTests when that mpSettingsConfigItem was a plain pointer instead of std::unique_ptr). So ensure that PythonTests that initialize VCL also call DeInitVCL, via a new private_deinitTestEnvironment, complementing the existing private_initTestEnvironment. However, while private_initTestEnvironment is called once (typically via UnoInProcess.setUp, which internally makes sure to only call it once) as soon as the first executed test needs it, private_deinitTestEnvironment must be called once after the lasts test needing it has executed. The only way that I found to do that is to override unittest.TextTestResult's stopTestRun method, which is called once after all tests have been executed. Hence a new test runner setup in unotest/source/python/org/libreoffice/unittest.py that is now called from solenv/gbuild/PythonTest.mk. That revealed a few places in PythonTests that didn't yet close/delete documents that they had opened, which has now been added. One remaining problem then is that classes like SwXTextDocument and friends call Application::GetSolarMutex from their dtors, via sw::UnoImplPtrDeleter (a "Smart pointer class ensuring that the pointed object is deleted with a locked SolarMutex", sw/inc/unobaseclass.hxx). That means that any PyUNO proxies to such C++ objects that remain alive after private_deinitTestEnvironment will cause issues at exit, when Python does a final garbage collection of those objects. The ultimate fix will be to remove that unhelpful UnoImplPtrDeleter and its locking of SolarMutex from the dtors of UNO objects; until then, the Python code is now sprinkled with some HACKs to make sure all those PyUNO proxies are released in a timely fashion (see the comment in unotest/source/python/org/libreoffice/unittest.py for details). (Also, it would probably help if UnoInProcess didn't keep a local self.xDoc around referencing (just) the last result of calling one of its open* methods, confusingly making it the responsibility of UnoInProcess to close that one document while making it the responsibility of the test code making the other UnoInProcess.open* calls to close any other documents.) Change-Id: Ief27c81e2b763e9be20cbf3234b68924315f13be Reviewed-on: https://gerrit.libreoffice.org/60100 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-04-14Fix typosAndrea Gelmini1-1/+1
Change-Id: I981cfdf97d132afdd4d3729ec76b6a3f4c62909a Reviewed-on: https://gerrit.libreoffice.org/52210 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2018-04-06Fix Python file URL construction on WindowsStephan Bergmann1-5/+2
...after d76281864b0e83812c0edf7490b1e8271e89fff5 "Create temp copies of test docs in Python/UITests" Change-Id: I4b6a5149c68f9e6cdc0a2037c07b50e8acc3623f Reviewed-on: https://gerrit.libreoffice.org/52486 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-04-03Create temp copies of test docs in Python/UITestsStephan Bergmann1-9/+29
...where necessary, so the tests will succeed if SRCDIR is a read-only tree. Change-Id: Iea4c52d5982d3eba079088ef1670ff557ce30c3f Reviewed-on: https://gerrit.libreoffice.org/52122 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-09-07unotest.py: refactor confusing mess of openDoc functionsMichael Stahl1-45/+18
Change-Id: I148332c639510c55dea2d09bc7aa695708fbf34c
2017-05-27tdf#97362: CheckBookmarks unittest migrated to python (check_bookmarks.py)jmzambon1-0/+12
Change-Id: Ie5fa41d4346d921ed905795b76ea3c3e90b3d4a2 Reviewed-on: https://gerrit.libreoffice.org/38080 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2017-03-13Revert "comphelper: fix MSVC hang in ThreadPool::shutdown()"Miklos Vajna1-3/+0
As it causes "unopkg.bin: /home/tdf/lode/jenkins/workspace/lo_gerrit/Config/linux_clang_dbgutil_64/comphelper/source/misc/threadpool.cxx:96: comphelper::ThreadPool::~ThreadPool(): Assertion `mbTerminate' failed." in <https://ci.libreoffice.org/job/lo_gerrit/8283/Config=linux_clang_dbgutil_64/console> and also locally. Revert till it's clear if that assert() should be a SAL_WARN() or unopkg has to be fixed. This reverts commit 9899ffd244dd367ba69dffe1f21f4f0222064a46. Change-Id: I72902f7da410012340aa8231d84c6871a3f7b976
2017-03-11comphelper: fix MSVC hang in ThreadPool::shutdown()Michael Stahl1-0/+3
Commit aa68c99d88fd7abe08c4aee5206c859a0cdba38e added some code using std::condition_variable to comphelper. Built with MSVC 2017, this causes many cppunittester.exe processes to deadlock in ThreadPool::shutdown(): maTasksChanged.notify_all(); This ultimately calls NtReleaseKeyedEvent(), which never returns. The reason appears to be a bug in Windows 7, for which a "hotfix"[1] is avaiable here, but it's apparently not distributed via Windows Update so we likely can't rely on users or even developers having this installed. However, the documentation of DllMain[2] and ExitProcess[3] indicates that during shutdown, by the time global destructors are invoked all threads other than the one that called ExitProcess have already been terminated. Returning from main() implicitly calls ExitProcess [4]. As it turns out the problem only happens for some CppUnitTests because soffice.bin will call ThreadPool::shutdown() from Desktop::doShutdown() while it is still safe. [1] http://support.microsoft.com/kb/2582203 [2] https://msdn.microsoft.com/en-US/library/windows/desktop/ms682583(v=vs.85).aspx [3] https://msdn.microsoft.com/en-us/library/windows/desktop/ms682658(v=vs.85).aspx [4] https://blogs.msdn.microsoft.com/oldnewthing/20100827-00/?p=13023 Change-Id: I6137461ca7efe9a5fbe4f8f8478fb96de3570469 Reviewed-on: https://gerrit.libreoffice.org/35066 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com>
2017-03-02Fix typosAndrea Gelmini1-1/+1
Change-Id: I139e6948e92a7bcdce5a2197b9d3754cb9549a33 Reviewed-on: https://gerrit.libreoffice.org/34781 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2016-10-26normalize existing emacs/vim mode-lines in python filesMichael Stahl1-2/+2
Bunch of these were setting C++ or Make modes and icky tabs... Also, reportedly Emacs can figure out to enable python-mode automatically. Change-Id: I50072488fb92cb4d27aa3f74f717a28ae3967543
2015-08-06unotest.py: call the magic bootstrap init function once onlyMichael Stahl1-1/+6
Change-Id: I5f775234f44c23386af19f973a9f895a39fa31d5
2015-06-26Python 2.7 compatibility for unotest.pyMatthew J. Francis1-0/+2
Change-Id: Ic7a54b211f6d55ff50cad0fde12058fe33e8892e
2015-06-23Uno api sidebar unit test tdf#91806Laurent Godard1-0/+14
- python test subsequentcheck - correct deck setTitle APi (UI update) - enhance UnoInProcess for flexiility in loading parameter Change-Id: Id04cb78c6162ac84fb3bfd8577f84763109d993e Reviewed-on: https://gerrit.libreoffice.org/16180 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
2015-03-29The --nofirststartwizard option is a no-opTor Lillqvist1-1/+1
Change-Id: Id481af38ebb51224f4f8493cccfb4eb4fd1e268f
2015-02-09Adapt file URL hackery to WindowsStephan Bergmann1-1/+4
Change-Id: Icee10aae97e9bcef7a3db7e966c1c4ef6780fc1d
2015-02-03copy test file to workdir to avoid overwritingLionel Elie Mamane1-0/+11
Change-Id: I2acc5cd6a57bb6a18f3f20177b3bcf2b8469a834 Reviewed-on: https://gerrit.libreoffice.org/14272 Reviewed-by: Lionel Elie Mamane <lionel@mamane.lu> Tested-by: Lionel Elie Mamane <lionel@mamane.lu>
2014-10-22framework, unotest: do not override UserInstallation from environmentMichael Stahl1-9/+0
The PythonTest_dbaccess_python may fail in incremental builds because of stale JVM path in workdir/unittest/user/config/javasettings_Linux_X86_64.xml so it's better to use the fresh UserInstallation that is already passed in from PythonTest.mk. To make that work, tolerate non-existing path in SubstitutePathVariables::SetPredefinedPathVariables() at least when running in the build environment, which is probably better than effectively running with "/" as UserInstallation anyway... This partially reverts commit 6dbb6275ebd1a4299099c3b6bc82ec4ee0e1fb86. Change-Id: I4d42d53c049056590662828360c4ce5a29af0f4b
2014-10-07fdo84315: add integration test for basic LibreOffice Base functionalityBjoern Michaelsen1-0/+25
Thanks to Stephan for helping with the test environment setup: sbergman@redhat.com: Do the same "set UserInstallation to user profile dir in test/user-template" in UnoInProcess's setUp as is done in test::BootstrapFixtureBase::setUp (unotest/source/cpp/bootstrapfixturebase.cxx) for CppunitTests. That way, these tests all use the workdir/unittest/ UserInstallation concurrently, but they at least do not run into the gotcha in SubstitutePathVariables::SetPredefinedPathVariables (framework/source/services/substitutepathvars.cxx) to only set the PREDEFVAR_USERPATH if PATH_EXISTS. Change-Id: Iad058098a4c69cb567e2d3222af3c7d4ba993271
2014-06-04Demystify magic poniesStephan Bergmann1-1/+1
Change-Id: I7e619daf8743d3471ece72d81f6cf1bb61741646
2013-09-22make the PythonTest run on WNTMichael Stahl1-1/+5
- fix the PATH - file url needs to start with file:///X:/ (three slashes, literal :) Change-Id: I0d16d1e946fd06ba5523961c23c3b46872c0c050
2013-06-18Migrate CheckFields unit test to pythonDavid Ostrovsky1-0/+17
Change-Id: Ia765b37888b4095a735015e792f06fc89201d1a3 Reviewed-on: https://gerrit.libreoffice.org/4294 Reviewed-by: Noel Power <noel.power@suse.com> Tested-by: Noel Power <noel.power@suse.com>
2013-04-27fdo#55814 migrate java unit test to pythonDavid Ostrovsky1-1/+5
Change-Id: Ib7ef29354f5d43abd9e67745dd6d3fccaec8612e
2013-04-26Make informative output more obviousStephan Bergmann1-3/+5
Change-Id: I9088da9fd2eb1b3ea6be6fda85e058abe8d57286
2013-04-22clean up PythonTestsDavid Ostrovsky1-3/+1
Conflicts: sw/PythonTest_sw_python.mk Change-Id: I8dc937df02efb686bf19d6606b9b42b6f0abf742
2013-04-09move Python tests in-processMichael Stahl1-0/+31
This is nice to make them more easily debuggable. A series of crude hacks are employed to bootstrap enough services from python so the current tests run. This is only tested with system python3 on Fedora. Change-Id: I5e06741e55ead7fddec41ff776ff8ca5d2399469 Reviewed-on: https://gerrit.libreoffice.org/3215 Reviewed-by: David Ostrovsky <David.Ostrovsky@gmx.de> Tested-by: David Ostrovsky <David.Ostrovsky@gmx.de>
2013-04-09set up python unit test infrastructureDavid Ostrovsky1-0/+215
Extract boostraping code from convwatch.py to unotest.py. Use python builtin unittest module as unit test framework. Specify the unit test modules in make file. Another option would be to use discover mode of unittest module. Add __pycache__ to global .gitignore to keep the source directory clean. Another option would be to deliver the unit tests to workdir prior to test execution. Currently only system python3 is supported. Change-Id: I2692817673f786e950e1176a17c7675f989755b6 Reviewed-on: https://gerrit.libreoffice.org/3214 Reviewed-by: David Ostrovsky <David.Ostrovsky@gmx.de> Tested-by: David Ostrovsky <David.Ostrovsky@gmx.de>