Skip to content

Commit

Permalink
add include substitution fix up tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zapster committed Jun 15, 2016
1 parent 455b03c commit 466e298
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/test_config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1151,6 +1151,35 @@ def test_include_substitution(self):
assert config['x'] == 42
assert config['y'] == 42

def test_include_substitution_fixup1(self):
with tempfile.NamedTemporaryFile('w') as fdin:
fdin.write('{ x : 10, y : ${x} }')
fdin.flush()

config = ConfigFactory.parse_string(
"""
{{ a : {{ include "{tmp_file}" }} }}
""".format(tmp_file=fdin.name)
)
assert config['a.x'] == 10
assert config['a.y'] == 10

def test_include_substitution_fixup2(self):
with tempfile.NamedTemporaryFile('w') as fdin:
fdin.write('{ x : 10, y : ${x} }')
fdin.flush()

config = ConfigFactory.parse_string(
"""
{{
a : {{ include "{tmp_file}" }}
a : {{ x : 42 }}
}}
""".format(tmp_file=fdin.name)
)
assert config['a.x'] == 42
assert config['a.y'] == 42

def test_substitution_override(self):
config = ConfigFactory.parse_string(
"""
Expand Down

0 comments on commit 466e298

Please sign in to comment.