Skip to content

TEST: Mock terminal output before testing changing default value #3193

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 3 commits into from
Mar 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions nipype/interfaces/base/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import simplejson as json

import pytest
from unittest import mock

from .... import config
from ....testing import example_data
Expand Down Expand Up @@ -456,17 +457,18 @@ def test_global_CommandLine_output(tmpdir):
ci = BET()
assert ci.terminal_output == "stream" # default case

nib.CommandLine.set_default_terminal_output("allatonce")
ci = nib.CommandLine(command="ls -l")
assert ci.terminal_output == "allatonce"
with mock.patch.object(nib.CommandLine, '_terminal_output'):
nib.CommandLine.set_default_terminal_output("allatonce")
ci = nib.CommandLine(command="ls -l")
assert ci.terminal_output == "allatonce"

nib.CommandLine.set_default_terminal_output("file")
ci = nib.CommandLine(command="ls -l")
assert ci.terminal_output == "file"
nib.CommandLine.set_default_terminal_output("file")
ci = nib.CommandLine(command="ls -l")
assert ci.terminal_output == "file"

# Check default affects derived interfaces
ci = BET()
assert ci.terminal_output == "file"
# Check default affects derived interfaces
ci = BET()
assert ci.terminal_output == "file"


def test_CommandLine_prefix(tmpdir):
Expand Down
3 changes: 1 addition & 2 deletions nipype/interfaces/tests/test_extra_dcm2nii.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def _fetch_data(datadir, dicoms):
"""Fetches some test DICOMs using datalad"""
api.install(path=datadir, source=DICOM_DIR)
data = os.path.join(datadir, dicoms)
api.get(path=data)
api.get(path=data, dataset=datadir)
except IncompleteResultsError as exc:
pytest.skip("Failed to fetch test data: %s" % str(exc))
return data
Expand All @@ -32,7 +32,6 @@ def _fetch_data(datadir, dicoms):

@pytest.mark.skipif(no_datalad, reason="Datalad required")
@pytest.mark.skipif(no_dcm2niix, reason="Dcm2niix required")
@pytest.mark.xfail(reason="Intermittent failures. Let's come back to this later.")
def test_dcm2niix_dti(fetch_data, tmpdir):
tmpdir.chdir()
datadir = tmpdir.mkdir("data").strpath
Expand Down