Add test for simple registry value inheritance.

This commit is contained in:
Valentin Lorentz 2019-08-25 00:07:24 +02:00
parent e878279e6a
commit 0b5bd625eb
2 changed files with 32 additions and 0 deletions

View File

@ -340,6 +340,8 @@ class Value(Group):
self._showDefault = showDefault
self._help = utils.str.normalizeWhitespace(help.strip())
self._callbacks = []
self._networkValue = False
self._channelValue = False
if setDefault:
self.setValue(default)

View File

@ -232,4 +232,34 @@ class SecurityTestCase(SupyTestCase):
self.assertFalse(g._private)
self.assertTrue(g.val._private)
class InheritanceTestCase(SupyTestCase):
def testChild(self):
parent = registry.String('foo', 'help')
parent._supplyDefault = True
self.assertTrue(parent._wasSet)
self.assertEqual(parent(), 'foo')
child = parent.get('child')
self.assertFalse(child._wasSet)
self.assertEqual(child(), 'foo')
parent.setValue('bar')
self.assertTrue(parent._wasSet)
self.assertEqual(parent(), 'bar')
self.assertFalse(child._wasSet)
self.assertEqual(child(), 'bar') # Takes the new parent value
child.setValue('baz')
self.assertTrue(parent._wasSet)
self.assertEqual(parent(), 'bar')
self.assertTrue(child._wasSet)
self.assertEqual(child(), 'baz')
parent.setValue('qux')
self.assertTrue(parent._wasSet)
self.assertEqual(parent(), 'qux')
self.assertTrue(child._wasSet)
self.assertEqual(child(), 'baz') # Keeps its own value
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: