Mercurial > piecrust2
diff 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 |
line wrap: on
line diff
--- a/tests/test_configuration.py Fri Aug 29 16:41:16 2014 -0700 +++ b/tests/test_configuration.py Fri Aug 29 16:42:15 2014 -0700 @@ -1,6 +1,9 @@ import copy +import yaml import pytest -from piecrust.configuration import Configuration, merge_dicts +from collections import OrderedDict +from piecrust.configuration import (Configuration, OrderedDictYAMLLoader, + merge_dicts) @pytest.mark.parametrize('values, expected', [ @@ -103,3 +106,19 @@ } assert config.get() == expected + +def test_ordered_loader(): + sample = """ +one: + two: fish + red: fish + blue: fish +two: + a: yes + b: no + c: null +""" + data = yaml.load(sample, Loader=OrderedDictYAMLLoader) + assert type(data) is OrderedDict + assert list(data['one'].keys()) == ['two', 'red', 'blue'] +