summaryrefslogtreecommitdiffstats
path: root/pyuno
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2017-10-03 18:01:54 +0200
committerStephan Bergmann <sbergman@redhat.com>2017-10-04 09:51:11 +0200
commita35e532a2d16dce25854b7c3cf27cc3a96a00b8e (patch)
tree42d58df684a679dfeb473fd8ac44c80755f3325f /pyuno
parenttdf#112689 Replace chained O(U)StringBuffer::append with operator+ in cui (diff)
downloadcore-a35e532a2d16dce25854b7c3cf27cc3a96a00b8e.tar.gz
core-a35e532a2d16dce25854b7c3cf27cc3a96a00b8e.zip
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@redhat.com> Tested-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'pyuno')
-rw-r--r--pyuno/qa/pytests/insertremovecells.py11
1 files changed, 8 insertions, 3 deletions
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