From 8ec0d8cd1f97e40139b4c3ab2b4a89065a9f7a8e Mon Sep 17 00:00:00 2001 From: Vasileios Karakasis Date: Tue, 26 May 2020 22:07:59 +0200 Subject: [PATCH] Fix site_config.get() for non-existent name-addressable objects --- reframe/core/config.py | 1 - unittests/test_config.py | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/reframe/core/config.py b/reframe/core/config.py index 96124f4303..85b1ae52c7 100644 --- a/reframe/core/config.py +++ b/reframe/core/config.py @@ -139,7 +139,6 @@ def get(self, option, default=None): # Element addressable by name x, found = x[1:], False for obj in value: - value, found = obj, True if obj['name'] == x: value, found = obj, True break diff --git a/unittests/test_config.py b/unittests/test_config.py index 746eeb95bc..8d95e77965 100644 --- a/unittests/test_config.py +++ b/unittests/test_config.py @@ -258,6 +258,11 @@ def test_select_subconfig(): assert site_config.get('environments/0/cxx') == 'CC' assert site_config.get('general/0/check_search_path') == ['c:d'] + # Test default values for non-existent name-addressable objects + # See https://github.com/eth-cscs/reframe/issues/1339 + assert site_config.get('modes/@foo/options') == [] + assert site_config.get('modes/10/options') == [] + # Test inexistent options site_config.select_subconfig('testsys') assert site_config.get('systems/1/name') is None