1515from docx .section import Sections
1616from docx .styles .styles import Styles
1717from docx .table import Table
18+ from docx .text .paragraph import Paragraph
1819
1920from helpers import test_docx , test_file
2021
@@ -41,6 +42,11 @@ def given_a_document_having_styles(context):
4142 context .document = Document (test_docx ('sty-having-styles-part' ))
4243
4344
45+ @given ('a document having three tables' )
46+ def given_a_document_having_three_tables (context ):
47+ context .document = Document (test_docx ('tbl-having-tables' ))
48+
49+
4450@given ('a single-section document having portrait layout' )
4551def given_a_single_section_document_having_portrait_layout (context ):
4652 context .document = Document (test_docx ('doc-add-section' ))
@@ -164,6 +170,8 @@ def then_document_paragraphs_is_a_list_containing_three_paragraphs(context):
164170 paragraphs = document .paragraphs
165171 assert isinstance (paragraphs , list )
166172 assert len (paragraphs ) == 3
173+ for paragraph in paragraphs :
174+ assert isinstance (paragraph , Paragraph )
167175
168176
169177@then ('document.sections is a Sections object' )
@@ -179,6 +187,16 @@ def then_document_styles_is_a_Styles_object(context):
179187 assert isinstance (styles , Styles )
180188
181189
190+ @then ('document.tables is a list containing three tables' )
191+ def then_document_tables_is_a_list_containing_three_tables (context ):
192+ document = context .document
193+ tables = document .tables
194+ assert isinstance (tables , list )
195+ assert len (tables ) == 3
196+ for table in tables :
197+ assert isinstance (table , Table )
198+
199+
182200@then ('the document contains a 2 x 2 table' )
183201def then_document_contains_2x2_table (context ):
184202 document = context .document
0 commit comments