mirror of
https://github.com/datafolklabs/cement.git
synced 2026-02-06 15:56:47 +00:00
Merge branch 'issue558' of https://github.com/ShipChain/cement into ShipChain-issue558
This commit is contained in:
commit
e4f9f3cca9
@ -152,12 +152,12 @@ class ConfigParserConfigHandler(config.ConfigHandler, RawConfigParser):
|
||||
env_var = re.sub('[^0-9a-zA-Z]+', '_', env_var)
|
||||
return env_var
|
||||
|
||||
def get(self, section, key):
|
||||
def get(self, section, key, **kwargs):
|
||||
env_var = self._get_env_var(section, key)
|
||||
if env_var in os.environ.keys():
|
||||
return os.environ[env_var]
|
||||
else:
|
||||
return RawConfigParser.get(self, section, key)
|
||||
return RawConfigParser.get(self, section, key, **kwargs)
|
||||
|
||||
def has_section(self, section):
|
||||
return RawConfigParser.has_section(self, section)
|
||||
|
||||
@ -54,3 +54,15 @@ def test_env_var_override():
|
||||
assert app.config.get('dummy', 'foo') == 'dummy-not-bar'
|
||||
section_dict = app.config.get_section_dict('dummy')
|
||||
assert section_dict['foo'] == 'dummy-not-bar'
|
||||
|
||||
|
||||
def test_get_boolean():
|
||||
with TestApp(config_section='testapp') as app:
|
||||
app.config.set('testapp', 'foobool', 'true')
|
||||
assert app.config['testapp'].getboolean('foobool') is True
|
||||
|
||||
app.config.set('testapp', 'foobool', 'no')
|
||||
assert app.config['testapp'].getboolean('foobool') is False
|
||||
|
||||
os.environ['TESTAPP_FOOBOOL'] = '1'
|
||||
assert app.config['testapp'].getboolean('foobool') is True
|
||||
|
||||
Loading…
Reference in New Issue
Block a user