mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-26 20:59:27 +01:00
Add test for simple registry value inheritance.
This commit is contained in:
parent
e878279e6a
commit
0b5bd625eb
@ -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)
|
||||
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user