11import os
2+ import shutil
23import tempfile
34from pathlib import Path
45import subprocess
56import shlex
67import time
78import sys
8- from gcsfs .core import GCSFileSystem
99
1010import pytest
1111from fsspec .implementations .local import LocalFileSystem
1212from fsspec .registry import register_implementation , _registry
1313
1414import fsspec
15- import requests
1615
1716
1817def pytest_addoption (parser ):
@@ -85,11 +84,18 @@ def pathlib_base(local_testdir):
8584
8685@pytest .fixture (scope = "session" )
8786def htcluster ():
88- proc = subprocess .Popen (
89- shlex .split ("htcluster startup" ),
90- stderr = subprocess .DEVNULL ,
91- stdout = subprocess .DEVNULL ,
92- )
87+ try :
88+ proc = subprocess .Popen (
89+ shlex .split ("htcluster startup" ),
90+ stderr = subprocess .DEVNULL ,
91+ stdout = subprocess .DEVNULL ,
92+ )
93+ except FileNotFoundError as err :
94+ if err .errno == 2 and 'htcluster' == err .filename :
95+ pytest .skip ("htcluster not installed" )
96+ else :
97+ raise
98+
9399 time .sleep (30 )
94100 yield
95101 proc .terminate ()
@@ -197,6 +203,11 @@ def docker_gcs():
197203 # assume using real API or otherwise have a server already set up
198204 yield os .environ ["STORAGE_EMULATOR_HOST" ]
199205 return
206+
207+ requests = pytest .importorskip ("requests" )
208+ if shutil .which ("docker" ) is None :
209+ pytest .skip ("docker not installed" )
210+
200211 container = "gcsfs_test"
201212 cmd = (
202213 "docker run -d -p 4443:4443 --name gcsfs_test fsouza/fake-gcs-server:latest -scheme " # noqa: E501
@@ -223,6 +234,11 @@ def docker_gcs():
223234
224235@pytest .fixture
225236def gcs (docker_gcs , tempdir , local_testdir , populate = True ):
237+ try :
238+ from gcsfs .core import GCSFileSystem
239+ except ImportError :
240+ pytest .skip ("gcsfs not installed" )
241+
226242 # from gcsfs.credentials import GoogleCredentials
227243 GCSFileSystem .clear_instance_cache ()
228244 gcs = fsspec .filesystem ("gcs" , endpoint_url = docker_gcs )
0 commit comments