|
1 | 1 | import pytest |
| 2 | +from packaging.version import Version |
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 | ) |
12 | 15 |
|
13 | 16 |
|
@@ -112,6 +115,32 @@ def test_create_interface_specs(): |
112 | 115 | assert "out_params" in current_params.keys() |
113 | 116 |
|
114 | 117 |
|
| 118 | +@pytest.mark.skipif(no_dipy() or Version(dipy_version()) < Version("1.4"), |
| 119 | + reason="DIPY >=1.4 required") |
| 120 | +def test_get_default_args(): |
| 121 | + from dipy.utils.deprecator import deprecated_params |
| 122 | + |
| 123 | + def test(dummy=11, x=3): |
| 124 | + return dummy, x |
| 125 | + |
| 126 | + @deprecated_params('x', None, '0.3', '0.5', alternative='test2.y') |
| 127 | + def test2(dummy=11, x=3): |
| 128 | + return dummy, x |
| 129 | + |
| 130 | + @deprecated_params(['dummy', 'x'], None, '0.3', alternative='test2.y') |
| 131 | + def test3(dummy=11, x=3): |
| 132 | + return dummy, x |
| 133 | + |
| 134 | + @deprecated_params(['dummy', 'x'], None, '0.3', '0.5', |
| 135 | + alternative='test2.y') |
| 136 | + def test4(dummy=11, x=3): |
| 137 | + return dummy, x |
| 138 | + |
| 139 | + expected_res = {'dummy': 11, 'x': 3} |
| 140 | + for func in [test, test2, test3, test4]: |
| 141 | + assert get_default_args(func) == expected_res |
| 142 | + |
| 143 | + |
115 | 144 | @pytest.mark.skipif(no_dipy(), reason="DIPY is not installed") |
116 | 145 | def test_dipy_to_nipype_interface(): |
117 | 146 | from dipy.workflows.workflow import Workflow |
@@ -178,3 +207,4 @@ def test_get_dipy_workflows(): |
178 | 207 | test_convert_to_traits_type() |
179 | 208 | test_create_interface_specs() |
180 | 209 | test_dipy_to_nipype_interface() |
| 210 | + test_get_default_args() |
0 commit comments