Mercurial > piecrust2
comparison tests/test_configuration.py @ 67:563ce5dd02af
I don't care what the YAML spec says, ordered maps are the only sane way.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Fri, 29 Aug 2014 16:42:15 -0700 |
parents | f485ba500df3 |
children | 10fc9c8bf682 |
comparison
equal
deleted
inserted
replaced
66:e4a24512b814 | 67:563ce5dd02af |
---|---|
1 import copy | 1 import copy |
2 import yaml | |
2 import pytest | 3 import pytest |
3 from piecrust.configuration import Configuration, merge_dicts | 4 from collections import OrderedDict |
5 from piecrust.configuration import (Configuration, OrderedDictYAMLLoader, | |
6 merge_dicts) | |
4 | 7 |
5 | 8 |
6 @pytest.mark.parametrize('values, expected', [ | 9 @pytest.mark.parametrize('values, expected', [ |
7 (None, {}), | 10 (None, {}), |
8 ({'foo': 'bar'}, {'foo': 'bar'}) | 11 ({'foo': 'bar'}, {'foo': 'bar'}) |
101 'child10': 'ten' | 104 'child10': 'ten' |
102 } | 105 } |
103 } | 106 } |
104 assert config.get() == expected | 107 assert config.get() == expected |
105 | 108 |
109 | |
110 def test_ordered_loader(): | |
111 sample = """ | |
112 one: | |
113 two: fish | |
114 red: fish | |
115 blue: fish | |
116 two: | |
117 a: yes | |
118 b: no | |
119 c: null | |
120 """ | |
121 data = yaml.load(sample, Loader=OrderedDictYAMLLoader) | |
122 assert type(data) is OrderedDict | |
123 assert list(data['one'].keys()) == ['two', 'red', 'blue'] | |
124 |