summaryrefslogtreecommitdiff
path: root/lib/spack/spack/test/cache_fetch.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/spack/spack/test/cache_fetch.py')
-rw-r--r--lib/spack/spack/test/cache_fetch.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/spack/spack/test/cache_fetch.py b/lib/spack/spack/test/cache_fetch.py
index 44a5275868..828dd81791 100644
--- a/lib/spack/spack/test/cache_fetch.py
+++ b/lib/spack/spack/test/cache_fetch.py
@@ -4,6 +4,7 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import os
+import sys
import pytest
@@ -13,13 +14,17 @@ import spack.config
from spack.fetch_strategy import CacheURLFetchStrategy, NoCacheError
from spack.stage import Stage
+is_windows = sys.platform == 'win32'
+
@pytest.mark.parametrize('_fetch_method', ['curl', 'urllib'])
def test_fetch_missing_cache(tmpdir, _fetch_method):
"""Ensure raise a missing cache file."""
testpath = str(tmpdir)
with spack.config.override('config:url_fetch_method', _fetch_method):
- fetcher = CacheURLFetchStrategy(url='file:///not-a-real-cache-file')
+ abs_pref = '' if is_windows else '/'
+ url = 'file://' + abs_pref + 'not-a-real-cache-file'
+ fetcher = CacheURLFetchStrategy(url=url)
with Stage(fetcher, path=testpath):
with pytest.raises(NoCacheError, match=r'No cache'):
fetcher.fetch()
@@ -31,7 +36,11 @@ def test_fetch(tmpdir, _fetch_method):
testpath = str(tmpdir)
cache = os.path.join(testpath, 'cache.tar.gz')
touch(cache)
- url = 'file:///{0}'.format(cache)
+ if is_windows:
+ url_stub = '{0}'
+ else:
+ url_stub = '/{0}'
+ url = 'file://' + url_stub.format(cache)
with spack.config.override('config:url_fetch_method', _fetch_method):
fetcher = CacheURLFetchStrategy(url=url)
with Stage(fetcher, path=testpath) as stage: