Skip to content

Commit 4dd8287

Browse files
committed
Why stopping supporting 3.7 3.8 when we can just make life harder for ourselves?
1 parent f909605 commit 4dd8287

File tree

2 files changed

+31
-10
lines changed

2 files changed

+31
-10
lines changed

phys2bids/tests/test_bids.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
2+
import sys
23
from csv import reader
3-
from importlib import resources
44

55
import pytest
66
import yaml
@@ -34,14 +34,26 @@ def test_bidsify_units():
3434
@pytest.mark.parametrize("test_sub", ["SBJ01", "sub-006", "006"])
3535
@pytest.mark.parametrize("test_ses", ["", "S05", "ses-42", "42"])
3636
def test_use_heuristic(tmpdir, test_sub, test_ses):
37-
ref = resources.files("phys2bids") / "heuristics"
38-
with resources.as_file(ref) as test_heur_path:
39-
test_heur_file = "heur_test_acq.py"
37+
test_heur_file = "heur_test_acq.py"
38+
test_input_file = "Test_belt_pulse_samefreq.acq"
39+
40+
if sys.version_info >= (3, 9):
41+
from importlib import resources
42+
43+
ref = resources.files("phys2bids") / "heuristics"
44+
with resources.as_file(ref) as test_heur_path:
45+
test_full_heur_path = os.path.join(test_heur_path, test_heur_file)
46+
ref = resources.files("phys2bids") / "tests/data"
47+
with resources.as_file(ref) as test_input_path:
48+
test_full_input_path = os.path.join(test_input_path, test_input_file)
49+
else:
50+
from pkg_resources import resource_filename
51+
52+
test_heur_path = resource_filename("phys2bids", "heuristics")
4053
test_full_heur_path = os.path.join(test_heur_path, test_heur_file)
41-
ref = resources.files("phys2bids") / "tests/data"
42-
with resources.as_file(ref) as test_input_path:
43-
test_input_file = "Test_belt_pulse_samefreq.acq"
54+
test_input_path = resource_filename("phys2bids", "tests/data")
4455
test_full_input_path = os.path.join(test_input_path, test_input_file)
56+
4557
test_outdir = tmpdir
4658
test_record_label = "test"
4759

phys2bids/tests/test_integration.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import re
55
import shutil
66
import subprocess
7-
from importlib import resources
7+
import sys
88
from os import remove
99
from os.path import isfile, join, split
1010

@@ -109,8 +109,17 @@ def test_integration_heuristic(skip_integration, multifreq_lab_file):
109109
test_ntp = 30
110110
test_tr = 1.2
111111
test_thr = 0.735
112-
ref = resources.files("phys2bids") / "heuristics"
113-
with resources.as_file(ref) as heur_path:
112+
113+
if sys.version_info >= (3, 9):
114+
from importlib import resources
115+
116+
ref = resources.files("phys2bids") / "heuristics"
117+
with resources.as_file(ref) as heur_path:
118+
test_heur = join(heur_path, "heur_test_multifreq.py")
119+
else:
120+
from pkg_resources import resource_filename
121+
122+
heur_path = resource_filename("phys2bids", "heuristics")
114123
test_heur = join(heur_path, "heur_test_multifreq.py")
115124

116125
# Move into folder

0 commit comments

Comments
 (0)