Kaydet (Commit) a35e532a authored tarafından Stephan Bergmann's avatar Stephan Bergmann

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/43092Reviewed-by: 's avatarStephan Bergmann <sbergman@redhat.com>
Tested-by: 's avatarStephan Bergmann <sbergman@redhat.com>
üst 9db36aac
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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment