def it_knows_how_many_paragraphs_in_each_section(self): document_elm = element( "w:document/w:body/(w:p,w:p,w:p/w:pPr/w:sectPr,w:p/w:pPr/w:sectPr,w:p,w:sectPr)" ) sections = Sections(document_elm, None) expected = [3, 1, 1] for i, section in enumerate(sections): assert len(section.paragraphs) == expected[i]
def it_can_iterate_over_its_Section_instances(self, Section_, section_, document_part_): document_elm = element( "w:document/w:body/(w:p/w:pPr/w:sectPr, w:sectPr)") sectPrs = document_elm.xpath("//w:sectPr") Section_.return_value = section_ sections = Sections(document_elm, document_part_) section_lst = [s for s in sections] assert Section_.call_args_list == [ call(sectPrs[0], document_part_), call(sectPrs[1], document_part_) ] assert section_lst == [section_, section_]
def it_can_access_its_Section_instances_by_slice(self, Section_, section_, document_part_): document_elm = element( "w:document/w:body/(w:p/w:pPr/w:sectPr,w:p/w:pPr/w:sectPr,w:sectPr)" ) sectPrs = document_elm.xpath("//w:sectPr") Section_.return_value = section_ sections = Sections(document_elm, document_part_) section_lst = sections[1:9] assert Section_.call_args_list == [ call(sectPrs[1], document_part_), call(sectPrs[2], document_part_) ] assert section_lst == [section_, section_]
def it_knows_how_many_sections_it_contains(self): sections = Sections( element("w:document/w:body/(w:p/w:pPr/w:sectPr, w:sectPr)"), None) assert len(sections) == 2
def sections(self): """|Sections| object providing access to each section in this document.""" return Sections(self._element, self._part)
def len_fixture(self, document_elm): sections = Sections(document_elm) return sections, 2
def index_fixture(self, document_elm): sections = Sections(document_elm) return sections, [0, 1]
def iter_fixture(self, document_elm): sections = Sections(document_elm, None) return sections, 2