mirror of https://github.com/scrapy/scrapy.git
Fix ShellTest.test_local_file on Windows
This commit is contained in:
parent
bdb28ac600
commit
2f510fd47d
|
|
@ -85,11 +85,9 @@ def add_http_if_no_scheme(url):
|
|||
|
||||
|
||||
def guess_scheme(url):
|
||||
"""Add an URL scheme if missing: file:// for filepath-like input or http:// otherwise."""
|
||||
parts = urlparse(url)
|
||||
if parts.scheme:
|
||||
return url
|
||||
# Note: this does not match Windows filepath
|
||||
"""Add an URL scheme if missing: file:// for filepath-like input or
|
||||
http:// otherwise."""
|
||||
# POSIX path
|
||||
if re.match(r'''^ # start with...
|
||||
(
|
||||
\. # ...a single dot,
|
||||
|
|
@ -99,7 +97,10 @@ def guess_scheme(url):
|
|||
)? # optional match of ".", ".." or ".blabla"
|
||||
/ # at least one "/" for a file path,
|
||||
. # and something after the "/"
|
||||
''', parts.path, flags=re.VERBOSE):
|
||||
''', url, flags=re.VERBOSE):
|
||||
return any_to_uri(url)
|
||||
# Windows drive-letter path
|
||||
elif re.match(r'''^[a-z]:\\''', url, flags=re.IGNORECASE):
|
||||
return any_to_uri(url)
|
||||
else:
|
||||
return add_http_if_no_scheme(url)
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ class ShellTest(ProcessTest, SiteTest, unittest.TestCase):
|
|||
|
||||
@defer.inlineCallbacks
|
||||
def test_local_file(self):
|
||||
filepath = join(tests_datadir, 'test_site/index.html')
|
||||
filepath = join(tests_datadir, 'test_site', 'index.html')
|
||||
_, out, _ = yield self.execute([filepath, '-c', 'item'])
|
||||
assert b'{}' in out
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue