From dfa3caccf2472989951fdb34f852bf8799e35c5d Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Tue, 24 Sep 2024 13:04:16 -0400 Subject: [PATCH] doctest: Avoid module-level testsetup, which conflicts with xdist --- sdcflows/utils/epimanip.py | 20 +++++++++++++------- sdcflows/workflows/fit/syn.py | 11 ----------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/sdcflows/utils/epimanip.py b/sdcflows/utils/epimanip.py index 6af5be7f21..a16e3a952d 100644 --- a/sdcflows/utils/epimanip.py +++ b/sdcflows/utils/epimanip.py @@ -23,13 +23,6 @@ """ Manipulation of EPI data. -.. testsetup:: - - >>> tmpdir = getfixture('tmpdir') - >>> tmp = tmpdir.chdir() # changing to a temporary directory - >>> nb.Nifti1Image(np.zeros((90, 90, 60)), None, None).to_filename( - ... tmpdir.join('epi.nii.gz').strpath) - """ @@ -42,6 +35,15 @@ def get_trt(in_meta, in_file=None): The first option is that a ``TotalReadoutTime`` field is found in the JSON sidecar: + .. testsetup:: + + >>> cwd = os.getcwd() + >>> tmpdir = getfixture('tmpdir') + >>> tmp = tmpdir.chdir() # changing to a temporary directory + >>> nb.Nifti1Image(np.zeros((90, 90, 60)), None, None).to_filename( + ... tmpdir.join('epi.nii.gz').strpath) + + >>> meta = {'TotalReadoutTime': 0.05251} >>> get_trt(meta) 0.05251 @@ -157,6 +159,10 @@ def get_trt(in_meta, in_file=None): Traceback (most recent call last): ValueError: + .. testcleanup:: + + >>> os.chdir(cwd) + .. admonition:: Thanks With thanks to Dr. Rorden for his thorough diff --git a/sdcflows/workflows/fit/syn.py b/sdcflows/workflows/fit/syn.py index a0783a6deb..5884173b9e 100644 --- a/sdcflows/workflows/fit/syn.py +++ b/sdcflows/workflows/fit/syn.py @@ -22,17 +22,6 @@ # """ Estimating the susceptibility distortions without fieldmaps. - -.. testsetup:: - - >>> tmpdir = getfixture('tmpdir') - >>> tmp = tmpdir.chdir() # changing to a temporary directory - >>> data = np.zeros((10, 10, 10, 1, 3)) - >>> data[..., 1] = 1 - >>> nb.Nifti1Image(data, None, None).to_filename( - ... tmpdir.join('field.nii.gz').strpath) - - """ from nipype.pipeline import engine as pe from nipype.interfaces import utility as niu