| 149 | self.assertEqual(f.parents['b'], 2) # look beyond maps[0] |
| 150 | |
| 151 | def test_ordering(self): |
| 152 | # Combined order matches a series of dict updates from last to first. |
| 153 | # This test relies on the ordering of the underlying dicts. |
| 154 | |
| 155 | baseline = {'music': 'bach', 'art': 'rembrandt'} |
| 156 | adjustments = {'art': 'van gogh', 'opera': 'carmen'} |
| 157 | |
| 158 | cm = ChainMap(adjustments, baseline) |
| 159 | |
| 160 | combined = baseline.copy() |
| 161 | combined.update(adjustments) |
| 162 | |
| 163 | self.assertEqual(list(combined.items()), list(cm.items())) |
| 164 | |
| 165 | def test_constructor(self): |
| 166 | self.assertEqual(ChainMap().maps, [{}]) # no-args --> one new dict |