From 8f2ffc6eacae69b855d24cde651ed31f97ffe77a Mon Sep 17 00:00:00 2001 From: Oliver Ruebel Date: Sat, 11 Nov 2023 21:54:06 -0800 Subject: [PATCH] Fix flake8 and move import check --- tests/unit/test_fsspec_streaming.py | 14 +++----------- tests/unit/utils.py | 10 ++++++++++ 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/tests/unit/test_fsspec_streaming.py b/tests/unit/test_fsspec_streaming.py index 43d193b5..29d29ac1 100644 --- a/tests/unit/test_fsspec_streaming.py +++ b/tests/unit/test_fsspec_streaming.py @@ -1,16 +1,8 @@ import unittest - - -try: - import s3fs - import fsspec - - HAVE_FSSPEC = True -except ImportError: - HAVE_FSSPEC = False - - from hdmf_zarr import NWBZarrIO +from .utils import check_s3fs_ffspec_installed + +HAVE_FSSPEC = check_s3fs_ffspec_installed() class TestFSSpecStreaming(unittest.TestCase): diff --git a/tests/unit/utils.py b/tests/unit/utils.py index 67f2e8e0..ebc1f732 100644 --- a/tests/unit/utils.py +++ b/tests/unit/utils.py @@ -34,6 +34,16 @@ def get_temp_filepath(): return temp_file.name +def check_s3fs_ffspec_installed(): + """Check if s3fs and ffspec are installed required for streaming access from S3""" + try: + import s3fs # noqa F401 + import fsspec # noqa F401 + return True + except ImportError: + return False + + ############################################ # Foo example data containers and specs ###########################################