Mercurial > piecrust2
comparison tests/test_configuration.py @ 440:32c7c2d219d2
performance: Refactor how data is managed to reduce copying.
* Make use of `collections.abc.Mapping` to better identify things that are
supposed to look like dictionaries.
* Instead of handling "overlay" of data in a dict tree in each different data
object, make all objects `Mapping`s and handle merging at a higher level
with the new `MergedMapping` object.
* Since this new object is read-only, remove the need for deep-copying of
app and page configurations.
* Split data classes into separate modules.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 28 Jun 2015 08:22:39 -0700 |
parents | f98451237371 |
children | 7e51d14097cb |
comparison
equal
deleted
inserted
replaced
439:c0700c6d9545 | 440:32c7c2d219d2 |
---|---|
11 (None, {}), | 11 (None, {}), |
12 ({'foo': 'bar'}, {'foo': 'bar'}) | 12 ({'foo': 'bar'}, {'foo': 'bar'}) |
13 ]) | 13 ]) |
14 def test_config_init(values, expected): | 14 def test_config_init(values, expected): |
15 config = Configuration(values) | 15 config = Configuration(values) |
16 assert config.get() == expected | 16 assert config.getAll() == expected |
17 | 17 |
18 | 18 |
19 def test_config_set_all(): | 19 def test_config_set_all(): |
20 config = Configuration() | 20 config = Configuration() |
21 config.setAll({'foo': 'bar'}) | 21 config.setAll({'foo': 'bar'}) |
22 assert config.get() == {'foo': 'bar'} | 22 assert config.getAll() == {'foo': 'bar'} |
23 | 23 |
24 | 24 |
25 def test_config_get_and_set(): | 25 def test_config_get_and_set(): |
26 config = Configuration({'foo': 'bar', 'answer': 42}) | 26 config = Configuration({'foo': 'bar', 'answer': 42}) |
27 assert config.get('foo') == 'bar' | 27 assert config.get('foo') == 'bar' |
123 'child1': 'other one', | 123 'child1': 'other one', |
124 'child2': 'two', | 124 'child2': 'two', |
125 'child10': 'ten' | 125 'child10': 'ten' |
126 } | 126 } |
127 } | 127 } |
128 assert config.get() == expected | 128 assert config.getAll() == expected |
129 | 129 |
130 | 130 |
131 def test_ordered_loader(): | 131 def test_ordered_loader(): |
132 sample = """ | 132 sample = """ |
133 one: | 133 one: |