Add tests for defaults
This commit is contained in:
parent
d947e709ce
commit
98089681bd
|
@ -19,10 +19,8 @@ class TestConfig(unittest.TestCase):
|
|||
|
||||
def test_safeGetBoolean(self):
|
||||
"""safeGetBoolean returns False for nonexistent option, no default"""
|
||||
self.assertIs(
|
||||
BMConfigParser().safeGetBoolean('nonexistent', 'nonexistent'),
|
||||
False
|
||||
)
|
||||
self.assertFalse(
|
||||
BMConfigParser().safeGetBoolean('nonexistent', 'nonexistent'))
|
||||
# no arg for default
|
||||
# pylint: disable=too-many-function-args
|
||||
with self.assertRaises(TypeError):
|
||||
|
@ -35,3 +33,19 @@ class TestConfig(unittest.TestCase):
|
|||
BMConfigParser().safeGetInt('nonexistent', 'nonexistent'), 0)
|
||||
self.assertEqual(
|
||||
BMConfigParser().safeGetInt('nonexistent', 'nonexistent', 42), 42)
|
||||
|
||||
def test_defaults(self):
|
||||
"""check use of config defaults"""
|
||||
self.assertEqual( # int
|
||||
BMConfigParser().getint('threads', 'receive'), 3)
|
||||
self.assertEqual( # str
|
||||
BMConfigParser().get('network', 'bind'), '')
|
||||
self.assertFalse( # bool
|
||||
BMConfigParser().getboolean('inventory', 'acceptmismatch'))
|
||||
|
||||
def test_defaults_safe(self):
|
||||
"""safeGet.. methods should use defaults"""
|
||||
self.assertEqual(
|
||||
BMConfigParser().safeGetInt('network', 'dandelion'), 90)
|
||||
self.assertEqual(
|
||||
BMConfigParser().safeGet('inventory', 'storage'), 'sqlite')
|
||||
|
|
Reference in New Issue
Block a user