diff options
author | Scott Talbert <swt@techie.net> | 2022-01-22 16:34:00 -0500 |
---|---|---|
committer | Scott Talbert <swt@techie.net> | 2022-01-22 16:35:04 -0500 |
commit | df926d69592d05dc24d40fb0e669e4f92005f28d (patch) | |
tree | 521296b46bbaf1ce342b29087e5f05ca1560b79e | |
parent | c84ec53601c12cc0ed1d5115463eb24cb24a6350 (diff) | |
download | pycurl-df926d69592d05dc24d40fb0e669e4f92005f28d.tar.gz |
tests: handle file:// URLs with spaces in paths
-rw-r--r-- | tests/unset_range_test.py | 4 | ||||
-rw-r--r-- | tests/write_abort_test.py | 4 | ||||
-rw-r--r-- | tests/write_cb_bogus_test.py | 4 |
3 files changed, 9 insertions, 3 deletions
diff --git a/tests/unset_range_test.py b/tests/unset_range_test.py index 2de5938..3167680 100644 --- a/tests/unset_range_test.py +++ b/tests/unset_range_test.py @@ -5,6 +5,7 @@ import os.path import pycurl import unittest +import urllib.request class UnsetRangeTest(unittest.TestCase): def setUp(self): @@ -20,7 +21,8 @@ class UnsetRangeTest(unittest.TestCase): # download bytes 0-9 of the script itself through the file:// protocol self.read = 0 - self.curl.setopt(pycurl.URL, 'file://' + os.path.abspath(__file__).replace('\\', '/')) + url = 'file:' + urllib.request.pathname2url(os.path.abspath(__file__)) + self.curl.setopt(pycurl.URL, url) self.curl.setopt(pycurl.WRITEFUNCTION, write_cb) self.curl.setopt(pycurl.RANGE, '0-9') self.curl.perform() diff --git a/tests/write_abort_test.py b/tests/write_abort_test.py index f125fcb..6969af2 100644 --- a/tests/write_abort_test.py +++ b/tests/write_abort_test.py @@ -6,6 +6,7 @@ import os.path import pycurl import sys import unittest +import urllib.request class WriteAbortTest(unittest.TestCase): def setUp(self): @@ -27,7 +28,8 @@ class WriteAbortTest(unittest.TestCase): pass # download the script itself through the file:// protocol into write_cb - self.curl.setopt(pycurl.URL, 'file://' + os.path.abspath(__file__).replace('\\', '/')) + url = 'file:' + urllib.request.pathname2url(os.path.abspath(__file__)) + self.curl.setopt(pycurl.URL, url) self.curl.setopt(pycurl.WRITEFUNCTION, write_cb) try: self.curl.perform() diff --git a/tests/write_cb_bogus_test.py b/tests/write_cb_bogus_test.py index 2972588..a0d44eb 100644 --- a/tests/write_cb_bogus_test.py +++ b/tests/write_cb_bogus_test.py @@ -6,6 +6,7 @@ import os.path import pycurl import sys import unittest +import urllib.request class WriteAbortTest(unittest.TestCase): def setUp(self): @@ -28,7 +29,8 @@ class WriteAbortTest(unittest.TestCase): def check(self, write_cb): # download the script itself through the file:// protocol into write_cb - self.curl.setopt(pycurl.URL, 'file://' + os.path.abspath(__file__).replace('\\', '/')) + url = 'file:' + urllib.request.pathname2url(os.path.abspath(__file__)) + self.curl.setopt(pycurl.URL, url) self.curl.setopt(pycurl.WRITEFUNCTION, write_cb) try: self.curl.perform() |