diff --git a/MRdataset/tests/simulate.py b/MRdataset/tests/simulate.py index 147c044..1529b88 100644 --- a/MRdataset/tests/simulate.py +++ b/MRdataset/tests/simulate.py @@ -17,7 +17,9 @@ THIS_DIR = Path(__file__).parent.resolve() -def sample_dicom_dataset(tmp_path='/tmp'): +def sample_dicom_dataset(tmp_path=None): + if not tmp_path: + tmp_path = tempfile.gettempdir() DATA_ARCHIVE = THIS_DIR / 'resources/example_dicom_data.zip' DATA_ROOT = Path(tmp_path) output_dir = DATA_ROOT / 'example_dicom_data' @@ -27,7 +29,9 @@ def sample_dicom_dataset(tmp_path='/tmp'): return DATA_ROOT / 'example_dicom_data' -def sample_bids_dataset(tmp_path='/tmp'): +def sample_bids_dataset(tmp_path=None): + if not tmp_path: + tmp_path = tempfile.gettempdir() DATA_ARCHIVE = THIS_DIR / 'resources/example_bids_data.zip' if not DATA_ARCHIVE.exists(): raise FileNotFoundError(f'Please download example datasets from ' @@ -40,7 +44,9 @@ def sample_bids_dataset(tmp_path='/tmp'): return DATA_ROOT / 'example_bids_dataset' -def sample_vertical_dataset(tmp_path='/tmp'): +def sample_vertical_dataset(tmp_path=None): + if not tmp_path: + tmp_path = tempfile.gettempdir() DATA_ARCHIVE = THIS_DIR / 'resources/vertical.zip' DATA_ROOT = Path(tmp_path) output_dir = DATA_ROOT / 'vertical/' @@ -109,7 +115,7 @@ def make_compliant_bids_dataset(num_subjects, try: with open(filepath, "r") as read_file: parameters = json.load(read_file) - except (FileNotFoundError, ValueError) as e: + except (FileNotFoundError, ValueError): continue parameters['RepetitionTime'] = repetition_time parameters['EchoTrainLength'] = echo_train_length diff --git a/MRdataset/tests/test_base.py b/MRdataset/tests/test_base.py index a975ad2..4bbe85f 100644 --- a/MRdataset/tests/test_base.py +++ b/MRdataset/tests/test_base.py @@ -5,11 +5,8 @@ import pytest from hypothesis import given, settings, HealthCheck -from MRdataset import BaseDataset, import_dataset -from MRdataset.dicom import DicomDataset from MRdataset.tests.conftest import dcm_dataset_strategy, \ vertical_dataset_strategy -from MRdataset.tests.simulate import make_compliant_test_dataset from MRdataset.utils import convert2ascii THIS_DIR = Path(__file__).parent.resolve() diff --git a/MRdataset/tests/test_bids.py b/MRdataset/tests/test_bids.py index 525f09b..63b5ca8 100644 --- a/MRdataset/tests/test_bids.py +++ b/MRdataset/tests/test_bids.py @@ -36,7 +36,7 @@ def test_dataset(num_subjects, for seq_id in seq_ids: mrd_num_subjects = set() - for subject, session, run, seq in mrd.traverse_horizontal(seq_id): + for subject, _, _, seq in mrd.traverse_horizontal(seq_id): mrd_num_subjects.add(subject) assert seq['RepetitionTime'].get_value() == repetition_time assert seq['EchoTrainLength'].get_value() == echo_train_length @@ -49,18 +49,18 @@ def test_dataset(num_subjects, def test_config_dict(): fake_ds_dir = make_compliant_bids_dataset(1, 1, 1, 1) with pytest.raises(FileNotFoundError): - mrd = import_dataset(fake_ds_dir, config_path='non-existent.json', - output_dir=fake_ds_dir, name='test_dataset', - ds_format='bids') + import_dataset(fake_ds_dir, config_path='non-existent.json', + output_dir=fake_ds_dir, name='test_dataset', + ds_format='bids') def test_invalid_output_dir(): fake_ds_dir = make_compliant_bids_dataset(1, 1, 1, 1) with pytest.raises(TypeError): - mrd = import_dataset(fake_ds_dir, - config_path=THIS_DIR / 'resources/bids-config.json', - output_dir=1, name='test_dataset', - ds_format='bids') + import_dataset(fake_ds_dir, + config_path=THIS_DIR / 'resources/bids-config.json', + output_dir=1, name='test_dataset', + ds_format='bids') def test_invalid_datatype():