diff --git a/test/common/resolver_test.py b/test/common/resolver_test.py index 5c5bc03..57fc626 100644 --- a/test/common/resolver_test.py +++ b/test/common/resolver_test.py @@ -6,6 +6,16 @@ class TestStringResolver(unittest.TestCase): + def test_resolve_no_custom_vars(self): + # given: + init_str_resolver("1.0", "token123") + init_str_resolver_custom_variables(None) + + # when: + resolved_string = resolve("Testing {VERSION}") + + # then: + self.assertEqual("Testing 1.0", resolved_string) def test_resolve_predefined(self): # given: diff --git a/valhalla/common/resolver.py b/valhalla/common/resolver.py index bdaf7c0..d213d59 100644 --- a/valhalla/common/resolver.py +++ b/valhalla/common/resolver.py @@ -29,7 +29,8 @@ def init_str_resolver(version: str, token: str): def init_str_resolver_custom_variables(variables: dict): global CUSTOM_VARIABLES_DICT - CUSTOM_VARIABLES_DICT.update(variables) + + CUSTOM_VARIABLES_DICT.update({} if variables is None else variables) for key, value in CUSTOM_VARIABLES_DICT.items(): info(f"Custom variable: {key} set to: {value}")