diff --git a/aiida/cmdline/commands/cmd_config.py b/aiida/cmdline/commands/cmd_config.py index f0a045d145..6ac6ef9dd7 100644 --- a/aiida/cmdline/commands/cmd_config.py +++ b/aiida/cmdline/commands/cmd_config.py @@ -143,7 +143,7 @@ def verdi_config_set(ctx, option, value, globally, append, remove): if not isinstance(current, list): echo.echo_critical(f'cannot append/remove to value: {current}') if append: - value = current + [value] + value = list(set(current + [value])) else: value = [item for item in current if item != value] diff --git a/tests/cmdline/commands/test_config.py b/tests/cmdline/commands/test_config.py index 39d81185b8..eac3d10e2b 100644 --- a/tests/cmdline/commands/test_config.py +++ b/tests/cmdline/commands/test_config.py @@ -49,10 +49,10 @@ def test_config_append_option(run_cli_command, config_with_profile_factory): """Test the `verdi config set --append` command when appending an option value.""" config = config_with_profile_factory() option_name = 'caching.enabled_for' - for value in ['x', 'y']: + for value in ['x', 'y', 'x', 'y']: options = ['config', 'set', '--append', option_name, value] run_cli_command(cmd_verdi.verdi, options, use_subprocess=False) - assert config.get_option(option_name, scope=get_profile().name) == ['x', 'y'] + assert sorted(config.get_option(option_name, scope=get_profile().name)) == ['x', 'y'] def test_config_remove_option(run_cli_command, config_with_profile_factory): @@ -60,7 +60,7 @@ def test_config_remove_option(run_cli_command, config_with_profile_factory): config = config_with_profile_factory() option_name = 'caching.disabled_for' - config.set_option(option_name, ['x', 'y'], scope=get_profile().name) + config.set_option(option_name, ['x', 'x', 'y', 'x'], scope=get_profile().name) options = ['config', 'set', '--remove', option_name, 'x'] run_cli_command(cmd_verdi.verdi, options, use_subprocess=False)