Skip to content

Commit 7ac9973

Browse files
committed
[Tests] Update section.test_children
1 parent a30d789 commit 7ac9973

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

test/test_section.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,29 @@ def test_children(self):
203203
with self.assertRaises(ValueError):
204204
sec.properties[0] = "prop"
205205

206+
# same tests with props alias
207+
prop = Property(name="prop2", parent=sec)
208+
newprop = Property(name="newprop2")
209+
210+
self.assertEqual(prop.parent, sec)
211+
self.assertEqual(sec.props[1], prop)
212+
self.assertEqual(len(sec.props), 2)
213+
self.assertIsNone(newprop.parent)
214+
215+
sec.props[1] = newprop
216+
self.assertEqual(newprop.parent, sec)
217+
self.assertEqual(sec.props[1], newprop)
218+
self.assertEqual(len(sec.props), 2)
219+
self.assertIsNone(prop.parent)
220+
221+
# Test set property fails
222+
with self.assertRaises(ValueError):
223+
sec.props[1] = Document()
224+
with self.assertRaises(ValueError):
225+
sec.props[1] = newsec
226+
with self.assertRaises(ValueError):
227+
sec.props[1] = "prop2"
228+
206229
def test_id(self):
207230
s = Section(name="S")
208231
self.assertIsNotNone(s.id)

0 commit comments

Comments
 (0)