Skip to content

Commit

Permalink
Merge pull request #13 from rubalo/master
Browse files Browse the repository at this point in the history
Fixing nested default parameters
  • Loading branch information
AdmiralObvious authored Aug 31, 2018
2 parents 7fcf260 + 80f1606 commit 4d39ac3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 8 additions & 0 deletions tests/test_vyper.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,14 @@ def test_default_post(self):
self.v.set_default('state', 'NYC')
self.assertEqual('NYC', self.v.get('state'))

def test_nested_default_post(self):
self._init_yaml()
self.assertTrue(self.v.is_set('clothing'))
self.assertFalse(self.v.is_set('clothing.gloves'))
self.assertNotEqual('leather', self.v.get('clothing.gloves'))
self.v.set_default('clothing.gloves', 'leather')
self.assertEqual('leather', self.v.get('clothing.gloves'))

def test_aliases(self):
self.v.register_alias('years', 'age')
self.v.set('years', 45)
Expand Down
5 changes: 3 additions & 2 deletions vyper/vyper.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,9 @@ def _find(self, key):
source = self._find(path[0])
if source is not None and isinstance(source, dict):
val = self._search_dict(source, path[1::])
log.debug('{0} found in nested config: {1}'.format(key, val))
return val
if val is not None:
log.debug('{0} found in nested config: {1}'.format(key, val))
return val

val = self._kvstore.get(key)
if val is not None:
Expand Down

0 comments on commit 4d39ac3

Please sign in to comment.