sd/qa/uitest/impress_tests2/tdf170386.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
New commits: commit 095b7b36f7ad501ca85deb7ca5818abf3d7204fe Author: Mike Kaganski <[email protected]> AuthorDate: Thu Mar 5 06:20:12 2026 +0100 Commit: Mike Kaganski <[email protected]> CommitDate: Thu Mar 5 08:07:55 2026 +0100 Let test_tdf170386 work on Windows After commit 54b76f7ca0ba07b3a8630ebcd30ea091050f0812 (Avoid parameter introduced in Python 3.12, 2026-02-13), it failed on Windows with Traceback (most recent call last): File "C:\louild\instdir\program\python-core-3.13.12\lib self.gen.throw(value) ~~~~~~~~~~~~~~^^^^^^^ File "C:\lo yield component File "C:/lo/core/sd/qa/uitest/impress_tests2/tdf170386.py", line 55, in test_tdf170386 xModel.storeAsURL(url, []) ~~~~~~~~~~~~~~~~~^^^^^^^^^ tdf170386.com.sun.star.task.ErrorCodeIOException: SfxBaseModel::impl_store <file:///C:/lo/build/tmp/tmp8d1tnp7g.odg> failed: 0x507(Error Area:Io Class:Access Code:7) at C:/lo/core/sfx2/source/doc/sfxbasemodel.cxx:3304 That was because tempfile.NamedTemporaryFile locks the created file on Windows, unless some specific conditions are true (documented at https://docs.python.org/3/library/tempfile.html). Fix it by creating a custom context manager, which checks platform, and calls tempfile.NamedTemporaryFile with delete_on_close=False on Windows. Change-Id: I122fabc89e469a02802c1e5237052d71cdf8bcdf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200994 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]> diff --git a/sd/qa/uitest/impress_tests2/tdf170386.py b/sd/qa/uitest/impress_tests2/tdf170386.py index 9960070f5a2a..c036517938bc 100644 --- a/sd/qa/uitest/impress_tests2/tdf170386.py +++ b/sd/qa/uitest/impress_tests2/tdf170386.py @@ -9,9 +9,21 @@ from uitest.framework import UITestCase from com.sun.star.awt import Point +from contextlib import contextmanager +from sys import platform import pathlib import tempfile +@contextmanager +def CreateNamedTemporaryFile(): + if platform == 'win32': + # On Windows, we are guaranteed to have delete_on_close (introduced in 3.12). + # With delete_on_close=False, it is possible to open file again. + tf = tempfile.NamedTemporaryFile(suffix=".odg", delete_on_close=False) + else: + tf = tempfile.NamedTemporaryFile(suffix=".odg") + yield tf + class tdf170386(UITestCase): def test_tdf170386(self): # Create a Draw document, lock its controllers, add a text shape, and apply bold to it. @@ -28,7 +40,7 @@ class tdf170386(UITestCase): # object used to collect text properties on save wasn't notified on the changes that # happened when the model was locked. - with tempfile.NamedTemporaryFile(suffix=".odg") as temp: + with CreateNamedTemporaryFile() as temp: url = pathlib.Path(temp.name).as_uri() with self.ui_test.create_doc_in_start_center("draw") as xModel:
