コード例 #1
0
ファイル: test_cmd.py プロジェクト: amoliu/nipype
    def test_run_4d_realign_without_arguments(self):
        with self.assertRaises(SystemExit) as cm:
            with capture_sys_output() as (stdout, stderr):
                nipype_cmd.main(['nipype_cmd', 'nipype.interfaces.nipy', 'FmriRealign4d'])

        exit_exception = cm.exception
        self.assertEqual(exit_exception.code, 2)

        error_message = """usage: nipype_cmd nipype.interfaces.nipy FmriRealign4d [-h]
                                                       [--between_loops [BETWEEN_LOOPS [BETWEEN_LOOPS ...]]]
                                                       [--ignore_exception]
                                                       [--loops [LOOPS [LOOPS ...]]]
                                                       [--slice_order SLICE_ORDER]
                                                       [--speedup [SPEEDUP [SPEEDUP ...]]]
                                                       [--start START]
                                                       [--time_interp TIME_INTERP]
                                                       [--tr_slices TR_SLICES]
                                                       in_file [in_file ...]
                                                       tr"""

        if PY2:
            error_message += """
nipype_cmd nipype.interfaces.nipy FmriRealign4d: error: too few arguments
"""
        elif PY3:
            error_message += """
nipype_cmd nipype.interfaces.nipy FmriRealign4d: error: the following arguments are required: in_file, tr
"""

        self.assertEqual(stderr.getvalue(), error_message)
        self.assertEqual(stdout.getvalue(), '')
コード例 #2
0
ファイル: test_cmd.py プロジェクト: heronjolin/nipype
    def test_run_4d_realign_without_arguments(self):
        with self.assertRaises(SystemExit) as cm:
            with capture_sys_output() as (stdout, stderr):
                nipype_cmd.main(["nipype_cmd", "nipype.interfaces.nipy", "FmriRealign4d"])

        exit_exception = cm.exception
        self.assertEqual(exit_exception.code, 2)

        self.assertEqual(
            stderr.getvalue(),
            """usage: nipype_cmd nipype.interfaces.nipy FmriRealign4d [-h]
                                                       [--between_loops [BETWEEN_LOOPS [BETWEEN_LOOPS ...]]]
                                                       [--ignore_exception IGNORE_EXCEPTION]
                                                       [--loops [LOOPS [LOOPS ...]]]
                                                       [--slice_order SLICE_ORDER]
                                                       [--speedup [SPEEDUP [SPEEDUP ...]]]
                                                       [--start START]
                                                       [--time_interp TIME_INTERP]
                                                       [--tr_slices TR_SLICES]
                                                       in_file [in_file ...]
                                                       tr
nipype_cmd nipype.interfaces.nipy FmriRealign4d: error: too few arguments
""",
        )
        self.assertEqual(stdout.getvalue(), "")
コード例 #3
0
ファイル: test_cmd.py プロジェクト: amoliu/nipype
    def test_run_4d_realign_without_arguments(self):
        with self.assertRaises(SystemExit) as cm:
            with capture_sys_output() as (stdout, stderr):
                nipype_cmd.main(
                    ['nipype_cmd', 'nipype.interfaces.nipy', 'FmriRealign4d'])

        exit_exception = cm.exception
        self.assertEqual(exit_exception.code, 2)

        error_message = """usage: nipype_cmd nipype.interfaces.nipy FmriRealign4d [-h]
                                                       [--between_loops [BETWEEN_LOOPS [BETWEEN_LOOPS ...]]]
                                                       [--ignore_exception]
                                                       [--loops [LOOPS [LOOPS ...]]]
                                                       [--slice_order SLICE_ORDER]
                                                       [--speedup [SPEEDUP [SPEEDUP ...]]]
                                                       [--start START]
                                                       [--time_interp TIME_INTERP]
                                                       [--tr_slices TR_SLICES]
                                                       in_file [in_file ...]
                                                       tr"""

        if PY2:
            error_message += """
nipype_cmd nipype.interfaces.nipy FmriRealign4d: error: too few arguments
"""
        elif PY3:
            error_message += """
nipype_cmd nipype.interfaces.nipy FmriRealign4d: error: the following arguments are required: in_file, tr
"""

        self.assertEqual(stderr.getvalue(), error_message)
        self.assertEqual(stdout.getvalue(), '')
コード例 #4
0
ファイル: test_cmd.py プロジェクト: veenasomareddy/nipype
    def test_run_4d_realign_help(self):
        with self.assertRaises(SystemExit) as cm:
            with capture_sys_output() as (stdout, stderr):
                nipype_cmd.main(['nipype_cmd', 'nipype.interfaces.nipy', 'FmriRealign4d', '-h'])

        exit_exception = cm.exception
        self.assertEqual(exit_exception.code, 0)

        self.assertEqual(stderr.getvalue(), '')
        self.assertTrue("Run FmriRealign4d" in stdout.getvalue())
コード例 #5
0
ファイル: test_cmd.py プロジェクト: veenasomareddy/nipype
    def test_main_returns_2_on_empty(self):
        with self.assertRaises(SystemExit) as cm:
            with capture_sys_output() as (stdout, stderr):
                nipype_cmd.main(['nipype_cmd'])

        exit_exception = cm.exception
        self.assertEqual(exit_exception.code, 2)

        self.assertEqual(stderr.getvalue(),
"""usage: nipype_cmd [-h] module interface
nipype_cmd: error: too few arguments
""")
        self.assertEqual(stdout.getvalue(), '')
コード例 #6
0
ファイル: test_cmd.py プロジェクト: amoliu/nipype
    def test_run_4d_realign_help(self):
        with self.assertRaises(SystemExit) as cm:
            with capture_sys_output() as (stdout, stderr):
                nipype_cmd.main([
                    'nipype_cmd', 'nipype.interfaces.nipy', 'FmriRealign4d',
                    '-h'
                ])

        exit_exception = cm.exception
        self.assertEqual(exit_exception.code, 0)

        self.assertEqual(stderr.getvalue(), '')
        self.assertTrue("Run FmriRealign4d" in stdout.getvalue())
コード例 #7
0
    def test_main_returns_2_on_empty(self):
        with self.assertRaises(SystemExit) as cm:
            with capture_sys_output() as (stdout, stderr):
                nipype_cmd.main(['nipype_cmd'])

        exit_exception = cm.exception
        self.assertEqual(exit_exception.code, 2)

        self.assertEqual(
            stderr.getvalue(), """usage: nipype_cmd [-h] module interface
nipype_cmd: error: too few arguments
""")
        self.assertEqual(stdout.getvalue(), '')
コード例 #8
0
ファイル: test_cmd.py プロジェクト: JohnGriffiths/nipype
    def test_list_nipy_interfacesp(self):
        with self.assertRaises(SystemExit) as cm:
            with capture_sys_output() as (stdout, stderr):
                nipype_cmd.main(['nipype_cmd', 'nipype.interfaces.nipy'])
        
        exit_exception = cm.exception
        self.assertEqual(exit_exception.code, 0)
        
        self.assertEqual(stderr.getvalue(), '')
        self.assertEqual(stdout.getvalue(),
"""Available Interfaces:
	SpaceTimeRealigner
	Similarity
	ComputeMask
	FitGLM
	EstimateContrast
	FmriRealign4d
""")
コード例 #9
0
    def test_list_nipy_interfacesp(self):
        with self.assertRaises(SystemExit) as cm:
            with capture_sys_output() as (stdout, stderr):
                nipype_cmd.main(['nipype_cmd', 'nipype.interfaces.nipy'])

        exit_exception = cm.exception
        self.assertEqual(exit_exception.code, 0)

        self.assertEqual(stderr.getvalue(), '')
        self.assertEqual(
            stdout.getvalue(), """Available Interfaces:
	SpaceTimeRealigner
	Similarity
	ComputeMask
	FitGLM
	EstimateContrast
	FmriRealign4d
""")
コード例 #10
0
ファイル: test_cmd.py プロジェクト: veenasomareddy/nipype
    def test_main_returns_0_on_help(self):
        with self.assertRaises(SystemExit) as cm:
            with capture_sys_output() as (stdout, stderr):
                nipype_cmd.main(['nipype_cmd', '-h'])

        exit_exception = cm.exception
        self.assertEqual(exit_exception.code, 0)

        self.assertEqual(stderr.getvalue(), '')
        self.assertEqual(stdout.getvalue(),
"""usage: nipype_cmd [-h] module interface

Nipype interface runner

positional arguments:
  module      Module name
  interface   Interface name

optional arguments:
  -h, --help  show this help message and exit
""")
コード例 #11
0
ファイル: test_cmd.py プロジェクト: amoliu/nipype
    def test_main_returns_0_on_help(self):
        with self.assertRaises(SystemExit) as cm:
            with capture_sys_output() as (stdout, stderr):
                nipype_cmd.main(['nipype_cmd', '-h'])

        exit_exception = cm.exception
        self.assertEqual(exit_exception.code, 0)

        self.assertEqual(stderr.getvalue(), '')
        self.assertEqual(
            stdout.getvalue(), """usage: nipype_cmd [-h] module interface

Nipype interface runner

positional arguments:
  module      Module name
  interface   Interface name

optional arguments:
  -h, --help  show this help message and exit
""")
コード例 #12
0
    def test_run_4d_realign_without_arguments(self):
        with self.assertRaises(SystemExit) as cm:
            with capture_sys_output() as (stdout, stderr):
                nipype_cmd.main(
                    ['nipype_cmd', 'nipype.interfaces.nipy', 'FmriRealign4d'])

        exit_exception = cm.exception
        self.assertEqual(exit_exception.code, 2)

        self.assertEqual(
            stderr.getvalue(),
            """usage: nipype_cmd nipype.interfaces.nipy FmriRealign4d [-h]
                                                       [--between_loops BETWEEN_LOOPS]
                                                       [--ignore_exception IGNORE_EXCEPTION]
                                                       [--loops LOOPS]
                                                       [--slice_order SLICE_ORDER]
                                                       [--speedup SPEEDUP]
                                                       [--start START]
                                                       [--time_interp TIME_INTERP]
                                                       [--tr_slices TR_SLICES]
                                                       in_file tr
nipype_cmd nipype.interfaces.nipy FmriRealign4d: error: too few arguments
""")
        self.assertEqual(stdout.getvalue(), '')
コード例 #13
0
    def test_list_nipy_interfacesp(self):
        with self.assertRaises(SystemExit) as cm:
            with capture_sys_output() as (stdout, stderr):
                nipype_cmd.main(["nipype_cmd", "nipype.interfaces.nipy"])

        # repeat twice in case nipy raises warnings
        with self.assertRaises(SystemExit) as cm:
            with capture_sys_output() as (stdout, stderr):
                nipype_cmd.main(["nipype_cmd", "nipype.interfaces.nipy"])
        exit_exception = cm.exception
        self.assertEqual(exit_exception.code, 0)

        self.assertEqual(stderr.getvalue(), "")
        self.assertEqual(
            stdout.getvalue(),
            """Available Interfaces:
	ComputeMask
	EstimateContrast
	FitGLM
	FmriRealign4d
	Similarity
	SpaceTimeRealigner
""",
        )
コード例 #14
0
    def test_main_returns_2_on_empty(self):
        with self.assertRaises(SystemExit) as cm:
            with capture_sys_output() as (stdout, stderr):
                nipype_cmd.main(["nipype_cmd"])

        exit_exception = cm.exception
        self.assertEqual(exit_exception.code, 2)

        if PY2:
            self.assertEqual(
                stderr.getvalue(),
                """usage: nipype_cmd [-h] module interface
nipype_cmd: error: too few arguments
""",
            )
        elif PY3:
            self.assertEqual(
                stderr.getvalue(),
                """usage: nipype_cmd [-h] module interface
nipype_cmd: error: the following arguments are required: module, interface
""",
            )

        self.assertEqual(stdout.getvalue(), "")