15
15
from docx .section import Sections
16
16
from docx .styles .styles import Styles
17
17
from docx .table import Table
18
+ from docx .text .paragraph import Paragraph
18
19
19
20
from helpers import test_docx , test_file
20
21
@@ -41,6 +42,11 @@ def given_a_document_having_styles(context):
41
42
context .document = Document (test_docx ('sty-having-styles-part' ))
42
43
43
44
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
+
44
50
@given ('a single-section document having portrait layout' )
45
51
def given_a_single_section_document_having_portrait_layout (context ):
46
52
context .document = Document (test_docx ('doc-add-section' ))
@@ -164,6 +170,8 @@ def then_document_paragraphs_is_a_list_containing_three_paragraphs(context):
164
170
paragraphs = document .paragraphs
165
171
assert isinstance (paragraphs , list )
166
172
assert len (paragraphs ) == 3
173
+ for paragraph in paragraphs :
174
+ assert isinstance (paragraph , Paragraph )
167
175
168
176
169
177
@then ('document.sections is a Sections object' )
@@ -179,6 +187,16 @@ def then_document_styles_is_a_Styles_object(context):
179
187
assert isinstance (styles , Styles )
180
188
181
189
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
+
182
200
@then ('the document contains a 2 x 2 table' )
183
201
def then_document_contains_2x2_table (context ):
184
202
document = context .document
0 commit comments