def test_process_markerless_collapsed(self): """Should be able to find collapsed markers in a markerless paragraph""" with XMLBuilder("ROOT") as ctx: ctx.P("Intro text") ctx.child_from_string( '<P><E T="03">Some term.</E> (a) First definition</P>') ctx.P("(b) Second definition") root = Node(label=['111', '22']) root = reg_text.RegtextParagraphProcessor().process(ctx.xml, root) root = NodeAccessor(root) self.assertEqual(['111', '22'], root.label) self.assertEqual(2, len(root.child_labels)) self.assertTrue(all(c.is_markerless for c in root.children)) keyterm_label = root.child_labels[1] self.assertTrue(len(keyterm_label) > 5) self.assertEqual(['a', 'b'], root[keyterm_label].child_labels)
def test_process_nested_uscode(self): with XMLBuilder("ROOT") as ctx: ctx.P("Some intro") with ctx.EXTRACT(): ctx.HD("The U.S. Code!") with ctx.USCODE(): ctx.P("(x)(1) Some content") ctx.P("(A) Sub-sub-paragraph") ctx.P("(i)(I) Even more nested") root = reg_text.RegtextParagraphProcessor().process(ctx.xml, Node()) root = NodeAccessor(root) self.assertEqual(root['p1'].text, "Some intro") self.assertEqual(root['p2']['p1'].title, 'The U.S. Code!') code = root['p2']['p2'] self.assertEqual(code.source_xml.tag, 'USCODE') self.assertEqual(code['x'].text, '(x)') self.assertEqual(code['x']['1'].text, '(1) Some content') self.assertEqual(code['x']['1']['A'].text, '(A) Sub-sub-paragraph') self.assertEqual(code['x']['1']['A']['i'].text, '(i)') self.assertEqual(code['x']['1']['A']['i']['I'].text, '(I) Even more nested')