Skip to content

Commit 1a42d5b

Browse files
TEST: Added possible locations to look for parrec2nii.
1 parent 7305e34 commit 1a42d5b

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

nibabel/tests/test_parrec2nii.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
""" Tests for the parrec2nii exe code
22
"""
3-
import imp, numpy
3+
import imp, numpy, sys, os
44
from numpy.testing import (assert_almost_equal,
55
assert_array_equal)
66
from nose.tools import assert_equal
@@ -9,7 +9,10 @@
99
from nibabel.tests.test_parrec import EG_PAR, VARY_PAR
1010
from os.path import dirname, join, isfile, basename
1111
from ..tmpdirs import InTemporaryDirectory
12-
BINDIR = join(dirname(dirname(dirname(__file__))), 'bin')
12+
## Possible locations of the parrec2nii executable;
13+
BINDIRS = [join(dirname(dirname(dirname(__file__))), 'bin'),
14+
sys.executable,
15+
join(os.environ['VIRTUALENV'],'bin')]
1316

1417

1518
AN_OLD_AFFINE = numpy.array(
@@ -24,10 +27,18 @@
2427
[ 0.86045705, 0. , 7.78655376, -58.25061211],
2528
[ 0. , 0. , 0. , 1. ]])
2629

30+
def find_parrec2nii():
31+
for bindir in BINDIRS:
32+
parrec2niiPath = join(bindir, 'parrec2nii')
33+
if isfile(parrec2niiPath):
34+
return parrec2niiPath
35+
else:
36+
raise AssertionError('Could not find parrec2nii executable.')
37+
2738
def test_parrec2nii_sets_qform_with_code2():
2839
"""Unit test that ensures that set_qform() is called on the new header.
2940
"""
30-
parrec2nii = imp.load_source('parrec2nii', join(BINDIR, 'parrec2nii'))
41+
parrec2nii = imp.load_source('parrec2nii', find_parrec2nii())
3142
parrec2nii.verbose.switch = False
3243

3344
parrec2nii.io_orientation = Mock()
@@ -67,7 +78,7 @@ def test_parrec2nii_save_load_qform_code():
6778
picks up the qform.
6879
"""
6980
import nibabel
70-
parrec2nii = imp.load_source('parrec2nii', join(BINDIR, 'parrec2nii'))
81+
parrec2nii = imp.load_source('parrec2nii', find_parrec2nii())
7182
parrec2nii.verbose.switch = False
7283

7384
opts = Mock()

0 commit comments

Comments
 (0)