From 39e1cf1fda20ffe8ad80e91da850881ddaba01ae Mon Sep 17 00:00:00 2001 From: Michiel Cottaar <MichielCottaar@protonmail.com> Date: Wed, 26 Feb 2020 18:42:33 +0000 Subject: [PATCH] BUG: actually test the stated bug I think these tests would have failed before refactoring --- tests/test_filetree/test_template.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/test_filetree/test_template.py b/tests/test_filetree/test_template.py index c4042078d..ba5122921 100644 --- a/tests/test_filetree/test_template.py +++ b/tests/test_filetree/test_template.py @@ -25,3 +25,12 @@ def test_get_variables(): assert {'subject': '01', 'session': 'A'} == utils.extract_variables('sub-{subject}/[ses-{session}]/T1w.nii.gz', 'sub-01/ses-A/T1w.nii.gz') with pytest.raises(ValueError): utils.extract_variables('sub-{subject}/[ses-{session}]/T1w.nii.gz', 'sub-01/other/T1w.nii.gz') + + +def test_multiple_optionals(): + with pytest.raises(KeyError): + utils.extract_variables('{var}[_{opt1}][_{opt2}]', 'test_foo') + assert {'var': 'test', 'opt1': None, 'opt2': None} == utils.extract_variables('{var}[_{opt1}][_{opt2}]', 'test') + assert {'var': 'test', 'opt1': 'oo', 'opt2': None} == utils.extract_variables('{var}[_f{opt1}][_{opt2}]', 'test_foo') + + -- GitLab