Do not interactively ask for settings when they are already set locally
This commit is contained in:
parent
05c533014e
commit
c0a39afa31
@ -66,16 +66,16 @@ class SettingsProxy(object):
|
||||
|
||||
def validate(self, interactive):
|
||||
if interactive:
|
||||
self._read_missing_settings_from_stdin(self.default, self.local)
|
||||
self._read_missing_settings_from_stdin(self.current, self.runtime)
|
||||
if self.get_errors():
|
||||
logger.error(u'Settings validation errors: %s',
|
||||
indent(self.get_errors_as_string()))
|
||||
raise SettingsError(u'Settings validation failed.')
|
||||
|
||||
def _read_missing_settings_from_stdin(self, default, local):
|
||||
for setting, value in default.iteritems():
|
||||
def _read_missing_settings_from_stdin(self, current, runtime):
|
||||
for setting, value in current.iteritems():
|
||||
if isinstance(value, basestring) and len(value) == 0:
|
||||
local[setting] = self._read_from_stdin(setting + u': ')
|
||||
runtime[setting] = self._read_from_stdin(setting + u': ')
|
||||
|
||||
def _read_from_stdin(self, prompt):
|
||||
if u'_PASSWORD' in prompt:
|
||||
|
||||
@ -157,6 +157,13 @@ class SettingsProxyTest(unittest.TestCase):
|
||||
self.settings.validate(interactive=True)
|
||||
self.assertEqual(interactive_input, self.settings.TEST)
|
||||
|
||||
def test_interactive_input_not_needed_when_setting_is_set_locally(self):
|
||||
self.settings.default['TEST'] = ''
|
||||
self.settings.local['TEST'] = 'test'
|
||||
self.settings._read_from_stdin = lambda _: self.fail(
|
||||
'Should not read from stdin')
|
||||
self.settings.validate(interactive=True)
|
||||
|
||||
|
||||
class FormatSettingListTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user