зеркало из https://github.com/mozilla/server-core.git
Bug 634728 - refuse to start if "extends" parameter references invalid filename - r=jrconlin
This commit is contained in:
Родитель
9abefe8e08
Коммит
f8f59bac67
|
@ -158,6 +158,8 @@ class Config(RawConfigParser):
|
|||
|
||||
def _extend(self, filename):
|
||||
"""Expand the config with another file."""
|
||||
if not os.path.isfile(filename):
|
||||
raise IOError('No such file: %s' % filename)
|
||||
parser = RawConfigParser()
|
||||
parser.read([filename])
|
||||
for section in parser.sections():
|
||||
|
|
|
@ -68,6 +68,14 @@ two = "a"
|
|||
more = stuff
|
||||
"""
|
||||
|
||||
_FILE_THREE = """\
|
||||
[DEFAULT]
|
||||
extends = no-no,no-no-no-no,no-no-no-no,theresnolimit
|
||||
|
||||
[one]
|
||||
foo = bar
|
||||
"""
|
||||
|
||||
|
||||
class ConfigTestCase(unittest.TestCase):
|
||||
|
||||
|
@ -79,6 +87,7 @@ class ConfigTestCase(unittest.TestCase):
|
|||
f.close()
|
||||
self.file_one = StringIO(_FILE_ONE % filename)
|
||||
self.file_two = filename
|
||||
self.file_three = StringIO(_FILE_THREE)
|
||||
|
||||
def tearDown(self):
|
||||
if '__STUFF__' in os.environ:
|
||||
|
@ -108,3 +117,8 @@ class ConfigTestCase(unittest.TestCase):
|
|||
# extends
|
||||
self.assertEquals(config.get('three', 'more'), 'stuff')
|
||||
self.assertEquals(config.get('one', 'two'), 'a')
|
||||
|
||||
def test_nofile(self):
|
||||
# if a user tries to use an inexistant file in extensios,
|
||||
# pops an error
|
||||
self.assertRaises(IOError, Config, self.file_three)
|
||||
|
|
Загрузка…
Ссылка в новой задаче