|
1 | 1 | import os |
| 2 | +import sys |
2 | 3 | from csv import reader |
3 | | -from importlib import resources |
4 | 4 |
|
5 | 5 | import pytest |
6 | 6 | import yaml |
@@ -34,14 +34,26 @@ def test_bidsify_units(): |
34 | 34 | @pytest.mark.parametrize("test_sub", ["SBJ01", "sub-006", "006"]) |
35 | 35 | @pytest.mark.parametrize("test_ses", ["", "S05", "ses-42", "42"]) |
36 | 36 | 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") |
40 | 53 | 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") |
44 | 55 | test_full_input_path = os.path.join(test_input_path, test_input_file) |
| 56 | + |
45 | 57 | test_outdir = tmpdir |
46 | 58 | test_record_label = "test" |
47 | 59 |
|
|
0 commit comments