Show More
@@ -246,11 +246,13 b' class Config(dict):' | |||||
246 | c = Config() |
|
246 | c = Config() | |
247 | dict.__setitem__(self, key, c) |
|
247 | dict.__setitem__(self, key, c) | |
248 | return c |
|
248 | return c | |
249 | else: |
|
249 | elif not key.startswith('_'): | |
250 | # undefined, create lazy value, used for container methods |
|
250 | # undefined, create lazy value, used for container methods | |
251 | v = LazyConfigValue() |
|
251 | v = LazyConfigValue() | |
252 | dict.__setitem__(self, key, v) |
|
252 | dict.__setitem__(self, key, v) | |
253 | return v |
|
253 | return v | |
|
254 | else: | |||
|
255 | raise KeyError | |||
254 |
|
256 | |||
255 | def __setitem__(self, key, value): |
|
257 | def __setitem__(self, key, value): | |
256 | if _is_section_key(key): |
|
258 | if _is_section_key(key): |
@@ -369,6 +369,14 b' class TestConfig(TestCase):' | |||||
369 | assert isinstance(foo, LazyConfigValue) |
|
369 | assert isinstance(foo, LazyConfigValue) | |
370 | self.assertIn('foo', cfg) |
|
370 | self.assertIn('foo', cfg) | |
371 |
|
371 | |||
|
372 | def test_getattr_private_missing(self): | |||
|
373 | cfg = Config() | |||
|
374 | self.assertNotIn('_repr_html_', cfg) | |||
|
375 | with self.assertRaises(AttributeError): | |||
|
376 | _ = cfg._repr_html_ | |||
|
377 | self.assertNotIn('_repr_html_', cfg) | |||
|
378 | self.assertEqual(len(cfg), 0) | |||
|
379 | ||||
372 | def test_getitem_not_section(self): |
|
380 | def test_getitem_not_section(self): | |
373 | cfg = Config() |
|
381 | cfg = Config() | |
374 | self.assertNotIn('foo', cfg) |
|
382 | self.assertNotIn('foo', cfg) |
General Comments 0
You need to be logged in to leave comments.
Login now