Skip to content

Commit ef53e4c

Browse files
committed
fix ci testing
1 parent 07fa5b3 commit ef53e4c

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

neo/test/rawiotest/common_rawio_test.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,21 @@
1919

2020
import logging
2121
import unittest
22+
import importlib.util
23+
import warnings
2224

2325
from neo.utils.datasets import download_dataset, get_local_testing_data_folder, default_testing_repo
2426

2527
from neo.test.rawiotest.tools import can_use_network
2628

2729
from neo.test.rawiotest import rawio_compliance as compliance
2830

29-
try:
30-
import datalad
31-
31+
datalad_spec = importlib.util.find_spec("datalad")
32+
if datalad_spec is not None:
3233
HAVE_DATALAD = True
33-
except:
34+
else:
3435
HAVE_DATALAD = False
36+
warnings.warn("datalad failure")
3537

3638
# url_for_tests = "https://portal.g-node.org/neo/" #This is the old place
3739
repo_for_test = default_testing_repo

neo/test/rawiotest/tools.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
import logging
66
import os
7+
import importlib.util
8+
79

810
logger = logging.getLogger("neo.test")
911

@@ -13,14 +15,18 @@ def can_use_network():
1315
Return True if network access is allowed
1416
"""
1517

18+
# env variable for local dev
1619
if os.environ.get("NEO_TESTS_NO_NETWORK", False):
1720
return False
18-
try:
19-
import datalad
20-
21+
22+
# check for datalad presence
23+
datalad_spec = importlib.util.find_spec("datalad")
24+
if datalad_spec is not None:
2125
HAVE_DATALAD = True
22-
except:
26+
else:
2327
HAVE_DATALAD = False
28+
2429
if not HAVE_DATALAD:
2530
return False
31+
2632
return True

0 commit comments

Comments
 (0)