|
1 | 1 | import pytest |
| 2 | +from distutils.version import LooseVersion |
2 | 3 | from collections import namedtuple |
3 | 4 | from ...base import traits, File, TraitedSpec, BaseInterfaceInputSpec |
4 | 5 | from ..base import ( |
|
8 | 9 | DipyBaseInterface, |
9 | 10 | no_dipy, |
10 | 11 | get_dipy_workflows, |
| 12 | + get_default_args, |
| 13 | + dipy_version |
11 | 14 | ) |
| 15 | +DIPY_1_14_LESS = LooseVersion(dipy_version()) < LooseVersion("1.14") |
12 | 16 |
|
13 | 17 |
|
14 | 18 | def test_convert_to_traits_type(): |
@@ -112,6 +116,32 @@ def test_create_interface_specs(): |
112 | 116 | assert "out_params" in current_params.keys() |
113 | 117 |
|
114 | 118 |
|
| 119 | +@pytest.mark.skipif(no_dipy() and DIPY_1_14_LESS, |
| 120 | + reason="DIPY is not installed") |
| 121 | +def test_get_default_args(): |
| 122 | + from dipy.utils.deprecator import deprecated_params |
| 123 | + |
| 124 | + def test(dummy=11, x=3): |
| 125 | + return dummy, x |
| 126 | + |
| 127 | + @deprecated_params('x', None, '0.3', '0.5', alternative='test2.y') |
| 128 | + def test2(dummy=11, x=3): |
| 129 | + return dummy, x |
| 130 | + |
| 131 | + @deprecated_params(['dummy', 'x'], None, '0.3', alternative='test2.y') |
| 132 | + def test3(dummy=11, x=3): |
| 133 | + return dummy, x |
| 134 | + |
| 135 | + @deprecated_params(['dummy', 'x'], None, '0.3', '0.5', |
| 136 | + alternative='test2.y') |
| 137 | + def test4(dummy=11, x=3): |
| 138 | + return dummy, x |
| 139 | + |
| 140 | + expected_res = {'dummy': 11, 'x': 3} |
| 141 | + for func in [test, test2, test3, test4]: |
| 142 | + assert get_default_args(func) == expected_res |
| 143 | + |
| 144 | + |
115 | 145 | @pytest.mark.skipif(no_dipy(), reason="DIPY is not installed") |
116 | 146 | def test_dipy_to_nipype_interface(): |
117 | 147 | from dipy.workflows.workflow import Workflow |
@@ -178,3 +208,4 @@ def test_get_dipy_workflows(): |
178 | 208 | test_convert_to_traits_type() |
179 | 209 | test_create_interface_specs() |
180 | 210 | test_dipy_to_nipype_interface() |
| 211 | + test_get_default_args() |
0 commit comments