def test_fileformatyaml_pass_with_substitutions():
"""Relative path to file should succeed.
Strictly speaking not a unit test.
"""
context = Context({
'k1': 'v1',
'k2': 'v2',
'k3': 'v3',
'k4': 'v4',
'k5': 'v5',
'fileFormatYamlIn': './tests/testfiles/testsubst.yaml',
'fileFormatYamlOut': './tests/testfiles/out/outsubst.yaml'})
fileformat.run_step(context)
assert context, "context shouldn't be None"
assert len(context) == 7, "context should have 7 items"
assert context['k1'] == 'v1'
assert context['fileFormatYamlIn'] == './tests/testfiles/testsubst.yaml'
assert context['fileFormatYamlOut'] == ('./tests/testfiles/out/'
'outsubst.yaml')
with open('./tests/testfiles/out/outsubst.yaml') as outfile:
outcontents = yaml.load(outfile, Loader=yaml.RoundTripLoader)
expected = {
'key': 'v1value1 !£$%# *',
'key2v2': 'blah',
# there is a comment here
'key3': [
'l1',
# and another
'!£$% * v3',
'l2', ['l31v4',
{'l32': ['l321',
'l322v5']
}
]
]
}
assert outcontents == expected
# atrociously lazy test clean-up
os.remove('./tests/testfiles/out/outsubst.yaml')
评论列表
文章目录