diff options
author | Lars Wirzenius <liw@liw.fi> | 2012-02-11 13:13:55 +0000 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2012-02-11 13:13:55 +0000 |
commit | 93c6814f56dff1ec2d5a30dd7acfacfac1458286 (patch) | |
tree | 636f0a11ba39045a3b160aaa86f0cda0642af8ad /cliapp/settings_tests.py | |
parent | 4ada1d38e78092b4b74bd7c273a42df45a537a5e (diff) | |
download | cliapp-93c6814f56dff1ec2d5a30dd7acfacfac1458286.tar.gz |
Make as_cp retain all sections from config files
Diffstat (limited to 'cliapp/settings_tests.py')
-rw-r--r-- | cliapp/settings_tests.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/cliapp/settings_tests.py b/cliapp/settings_tests.py index 8a20b18..59f357e 100644 --- a/cliapp/settings_tests.py +++ b/cliapp/settings_tests.py @@ -386,4 +386,24 @@ bar = ping, pong self.assertEqual(cp.get('config', 'foo'), '1') self.assertEqual(cp.get('config', 'bar'), 'yo') + def test_exports_all_config_sections_via_as_cp(self): + + def mock_open(filename, mode=None): + return StringIO.StringIO('''\ +[config] +foo = yeehaa + +[other] +bar = dodo +''') + + self.settings.string(['foo'], 'foo help', default='foo') + self.settings.config_files = ['whatever.conf'] + self.settings.load_configs(open=mock_open) + cp = self.settings.as_cp() + + self.assertEqual(sorted(cp.sections()), ['config', 'other']) + self.assertEqual(cp.get('config', 'foo'), 'yeehaa') + self.assertEqual(cp.options('other'), ['bar']) + self.assertEqual(cp.get('other', 'bar'), 'dodo') |