diff --git a/autocmake/parse_yaml.py b/autocmake/parse_yaml.py index 1824b38..447d16d 100644 --- a/autocmake/parse_yaml.py +++ b/autocmake/parse_yaml.py @@ -1,5 +1,6 @@ def parse_yaml(stream, override={}): import yaml + import sys from autocmake.interpolate import interpolate try: @@ -14,3 +15,23 @@ def parse_yaml(stream, override={}): config = interpolate(config, config) return config + + +def test_parse_yaml(): + import tempfile + import os + + text = """foo: bar +this: that +var: '%(foo)'""" + + # we save this text to a temporary file + file_name = tempfile.mkstemp()[1] + with open(file_name, 'w') as f: + f.write(text) + + with open(file_name, 'r') as f: + assert parse_yaml(f) == {'foo': 'bar', 'this': 'that', 'var': 'bar'} + + # we remove the temporary file + os.unlink(file_name)