Fix uninitialized variable in deserialize method (#18037)

The bug was introduced with commit 06d4f4ad0e.
Added a simple test.
This commit is contained in:
Thilo Uttendorfer 2016-10-21 04:54:16 +02:00 committed by jctanner
parent 0a60cceaf0
commit cf0da0948d
2 changed files with 12 additions and 1 deletions

View file

@ -251,7 +251,7 @@ class Block(Base, Become, Conditional, Taggable):
p = TaskInclude()
elif parent_type == 'HandlerTaskInclude':
p = HandlerTaskInclude()
p.deserialize(pb_data)
p.deserialize(parent_data)
self._parent = p
self._dep_chain = self._parent.get_dep_chain()

View file

@ -75,3 +75,14 @@ class TestBlock(unittest.TestCase):
self.assertEqual(len(b.block), 1)
self.assertIsInstance(b.block[0], Task)
def test_deserialize(self):
ds = dict(
block = [dict(action='block')],
rescue = [dict(action='rescue')],
always = [dict(action='always')],
)
b = Block.load(ds)
data = dict(parent = ds, parent_type = 'Block')
b.deserialize(data)
self.assertIsInstance(b._parent, Block)