Skip to content

Commit

Permalink
Fix required(file()) syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
jrouly committed May 11, 2020
1 parent d242459 commit 8c39103
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyhocon/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 10 additions & 0 deletions tests/test_config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 8c39103

Please sign in to comment.