except NoOptionError:
sect_found = True
+ if section in self.DEFAULTS and opt in self.DEFAULTS[section]:
+ return self.DEFAULTS[section][opt]
+
if not sect_found:
- if section in self.DEFAULTS and opt in self.DEFAULTS[section]:
- return self.DEFAULTS[section][opt]
- else:
- raise errors.ConfigError('no section %s' % section)
+ raise errors.ConfigError('no section %s' % section)
else:
- if opt in self.DEFAULTS[section]:
- return self.DEFAULTS[section][opt]
- else:
- raise errors.ConfigError('no opt: %s in section %s' \
- % (opt, section))
+ raise errors.ConfigError('no opt: %s in section %s' \
+ % (opt, section))
def check_opt(self, opt, section='general'):
if section in self.DEFAULTS and \
self.get, 'not_exists_section', 'key')
@Fixture(project='project1.ini')
+ def test_no_such_option(self):
+ '''test no such option'''
+ self.assertRaises(errors.ConfigError,
+ self.get, 'section', 'not_exists_option')
+
+ @Fixture(project='project1.ini')
def test_simple_get(self):
'''get value when one config file provides'''
self.assertEqual('projv2', self.get('section', 'proj_only_key'))