add test for parse_yaml
This commit is contained in:
parent
3565e2d885
commit
d7df341793
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user