-
Notifications
You must be signed in to change notification settings - Fork 532
fix+tst: ensure no pybids does not break testing #2248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
78c15e4
fix+tst: ensure no pybids does not break testing
mgxd 3fda1c7
tst: add condaforge before installing python
mgxd 77fb3c4
doctest: less SKIP comments
mgxd 08ec2b3
ref+tst: allow bidsgrabber to initialize without pybids, grab depende…
mgxd af459a8
tst: fix travis file
mgxd 0b16c85
rev: initiate fields as None
mgxd bb0ecff
tst+rf: run pybids with travis, minor tweaks to interface
mgxd ac45369
fix: skip resource monitor test until consistent
mgxd c87399e
rev: set traits inside __init__
mgxd 20eccd3
Merge branch 'master' of git://github.com/nipy/nipype into fix/nipype…
mgxd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import os | ||
import json | ||
import sys | ||
|
||
import pytest | ||
from nipype.interfaces.bids_utils import BIDSDataGrabber | ||
from nipype.utils.filemanip import dist_is_editable | ||
|
||
have_pybids = True | ||
try: | ||
import bids | ||
from bids import grabbids as gb | ||
filepath = os.path.realpath(os.path.dirname(bids.__file__)) | ||
datadir = os.path.realpath(os.path.join(filepath, 'grabbids/tests/data/')) | ||
except ImportError: | ||
have_pybids = False | ||
|
||
|
||
# There are three reasons these tests will be skipped: | ||
@pytest.mark.skipif(not have_pybids, | ||
reason="Pybids is not installed") | ||
@pytest.mark.skipif(sys.version_info < (3, 0), | ||
reason="Pybids no longer supports Python 2") | ||
@pytest.mark.skipif(not dist_is_editable('pybids'), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is this bit necessary? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
reason="Pybids is not installed in editable mode") | ||
def test_bids_grabber(tmpdir): | ||
tmpdir.chdir() | ||
bg = BIDSDataGrabber() | ||
bg.inputs.base_dir = os.path.join(datadir, 'ds005') | ||
bg.inputs.subject = '01' | ||
results = bg.run() | ||
assert os.path.basename(results.outputs.anat[0]) == 'sub-01_T1w.nii.gz' | ||
assert os.path.basename(results.outputs.func[0]) == ( | ||
'sub-01_task-mixedgamblestask_run-01_bold.nii.gz') | ||
|
||
|
||
@pytest.mark.skipif(not have_pybids, | ||
reason="Pybids is not installed") | ||
@pytest.mark.skipif(sys.version_info < (3, 0), | ||
reason="Pybids no longer supports Python 2") | ||
@pytest.mark.skipif(not dist_is_editable('pybids'), | ||
reason="Pybids is not installed in editable mode") | ||
def test_bids_fields(tmpdir): | ||
tmpdir.chdir() | ||
bg = BIDSDataGrabber(infields = ['subject'], outfields = ['dwi']) | ||
bg.inputs.base_dir = os.path.join(datadir, 'ds005') | ||
bg.inputs.subject = '01' | ||
bg.inputs.output_query['dwi'] = dict(modality='dwi') | ||
results = bg.run() | ||
assert os.path.basename(results.outputs.dwi[0]) == 'sub-01_dwi.nii.gz' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can replace this with the standard header that changes to the testing/data folder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't we skipping these tests anyways since it would require pybids to be installed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct, but we can make a directory
ds005
with a dummy file (since git does not store empty directories), just not call the bidsgrabber run function. we won't actually call pybids here.