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>
This commit is contained in:
@@ -1,11 +1,13 @@
|
|||||||
|
import platform
|
||||||
|
import re
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from os import getenv, path
|
from os import getenv, path
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from urllib.parse import quote
|
from urllib.request import pathname2url
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from urllib import quote
|
from urllib import pathname2url
|
||||||
|
|
||||||
from org.libreoffice.unotest import pyuno, mkPropertyValue
|
from org.libreoffice.unotest import pyuno, mkPropertyValue
|
||||||
|
|
||||||
@@ -28,7 +30,10 @@ class InsertRemoveCells(unittest.TestCase):
|
|||||||
('ReadOnly', False)
|
('ReadOnly', False)
|
||||||
))
|
))
|
||||||
tdoc_dir = getenv('TDOC')
|
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)
|
doc = desktop.loadComponentFromURL(url, "_blank", 0, load_props)
|
||||||
|
|
||||||
sheet = doc.Sheets.Sheet1
|
sheet = doc.Sheets.Sheet1
|
||||||
|
Reference in New Issue
Block a user