Skip to content

Commit

Permalink
Add more information to duplicate key warnings in config.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
jo-basevi committed Aug 20, 2024
1 parent fad94a4 commit cddbef6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions payu/fsops.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ def construct_mapping(self, node, deep=False):
if key in mapping:
warnings.warn(
"Duplicate key found in config.yaml: "
f"key '{key}' with value '{value}' "
f"(original value: '{mapping[key]}')"
f"key '{key}' with value '{value}'. "
f"This overwrites the original value: '{mapping[key]}'"
)
mapping[key] = value

Expand Down
4 changes: 2 additions & 2 deletions test/test_payu.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,8 @@ def test_read_config_yaml_duplicate_key():
file.write(config_content)

# Test read config passes without an error but a warning is raised
warn_msg = r"Duplicate key found in config.yaml: key 'pbs_flags' with "
warn_msg += r"value 'value2' \(original value: 'value1'\)"
warn_msg = "Duplicate key found in config.yaml: key 'pbs_flags' with "
warn_msg += "value 'value2'. This overwrites the original value: 'value1'"
with pytest.warns(UserWarning, match=warn_msg):
payu.fsops.read_config(config_path)

Expand Down

0 comments on commit cddbef6

Please sign in to comment.