[Libreoffice-commits] core.git: pyuno/qa
Stephan Bergmann
sbergman at redhat.com
Wed Oct 4 07:51:36 UTC 2017
pyuno/qa/pytests/insertremovecells.py | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
New commits:
commit a35e532a2d16dce25854b7c3cf27cc3a96a00b8e
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Tue Oct 3 18:01:54 2017 +0200
Fix PythonTest_pyuno_pytests_insertremovecells on Windows
...where the original code caused an "Unsupported URL <file://C%3A/...>" error,
while just using pathname2url instead of quote caused "Unsupported URL
<file:///C://...>", so had to add the silly re.sub. Hopefully keeps working
with all sorts of Python 2 and 3 that we want to support. (And is there really
no better way to convert a pathname to a file URL in Python?)
Change-Id: I43f450707fe5206a1e6b91918962d2d90a880463
Reviewed-on: https://gerrit.libreoffice.org/43092
Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
Tested-by: Stephan Bergmann <sbergman at redhat.com>
diff --git a/pyuno/qa/pytests/insertremovecells.py b/pyuno/qa/pytests/insertremovecells.py
index 5e29f3256c7f..0d7979c4c8d1 100644
--- a/pyuno/qa/pytests/insertremovecells.py
+++ b/pyuno/qa/pytests/insertremovecells.py
@@ -1,11 +1,13 @@
+import platform
+import re
import unittest
from os import getenv, path
try:
- from urllib.parse import quote
+ from urllib.request import pathname2url
except ImportError:
- from urllib import quote
+ from urllib import pathname2url
from org.libreoffice.unotest import pyuno, mkPropertyValue
@@ -28,7 +30,10 @@ class InsertRemoveCells(unittest.TestCase):
('ReadOnly', False)
))
tdoc_dir = getenv('TDOC')
- url = 'file://' + quote(path.join(tdoc_dir, 'fdo74824.ods'))
+ tdoc_path = pathname2url(path.join(tdoc_dir, 'fdo74824.ods'))
+ if platform.system() == 'Windows':
+ tdoc_path = re.sub(r'^//(/[A-Za-z]:/)/', r'\1', tdoc_path)
+ url = 'file://' + tdoc_path
doc = desktop.loadComponentFromURL(url, "_blank", 0, load_props)
sheet = doc.Sheets.Sheet1
More information about the Libreoffice-commits
mailing list