From 0b653ec1e891fe199c2ac41fcdff74cc0c435f8b Mon Sep 17 00:00:00 2001 From: Michel Rouly Date: Mon, 25 May 2020 23:16:38 -0400 Subject: [PATCH] Fix required(file()) syntax (#229) --- pyhocon/config_parser.py | 2 +- tests/test_config_parser.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/pyhocon/config_parser.py b/pyhocon/config_parser.py index 913c6195..09e8b9a8 100644 --- a/pyhocon/config_parser.py +++ b/pyhocon/config_parser.py @@ -314,7 +314,7 @@ def include_config(instring, loc, token): else: file = value elif len(final_tokens) == 2: # include url("test") or file("test") - value = final_tokens[1].value if isinstance(token[1], ConfigQuotedString) else final_tokens[1] + value = final_tokens[1].value if isinstance(final_tokens[1], ConfigQuotedString) else final_tokens[1] if final_tokens[0] == 'url': url = value else: diff --git a/tests/test_config_parser.py b/tests/test_config_parser.py index 9bb67f20..a868c53e 100644 --- a/tests/test_config_parser.py +++ b/tests/test_config_parser.py @@ -1217,6 +1217,16 @@ def test_include_required_file(self): } assert expected == config + config2 = ConfigFactory.parse_string( + """ + a { + include required(file("samples/cat.conf")) + t = 2 + } + """ + ) + assert expected == config2 + def test_include_missing_required_file(self): with pytest.raises(IOError): ConfigFactory.parse_string(