11
11
# given ===================================================
12
12
13
13
14
+ @given ("a _Cell object with paragraphs and tables" )
15
+ def given_a_cell_with_paragraphs_and_tables (context : Context ):
16
+ context .cell = (
17
+ Document (test_docx ("blk-paras-and-tables" )).tables [1 ].rows [0 ].cells [0 ]
18
+ )
19
+
20
+
21
+ @given ("a Document object with paragraphs and tables" )
22
+ def given_a_document_with_paragraphs_and_tables (context : Context ):
23
+ context .document = Document (test_docx ("blk-paras-and-tables" ))
24
+
25
+
14
26
@given ("a document containing a table" )
15
27
def given_a_document_containing_a_table (context : Context ):
16
28
context .document = Document (test_docx ("blk-containing-table" ))
17
29
18
30
31
+ @given ("a Footer object with paragraphs and tables" )
32
+ def given_a_footer_with_paragraphs_and_tables (context : Context ):
33
+ context .footer = Document (test_docx ("blk-paras-and-tables" )).sections [0 ].footer
34
+
35
+
36
+ @given ("a Header object with paragraphs and tables" )
37
+ def given_a_header_with_paragraphs_and_tables (context : Context ):
38
+ context .header = Document (test_docx ("blk-paras-and-tables" )).sections [0 ].header
39
+
40
+
19
41
@given ("a paragraph" )
20
42
def given_a_paragraph (context : Context ):
21
43
context .document = Document ()
@@ -40,6 +62,34 @@ def when_add_table(context: Context):
40
62
# then =====================================================
41
63
42
64
65
+ @then ("cell.iter_inner_content() produces the block-items in document order" )
66
+ def then_cell_iter_inner_content_produces_the_block_items (context : Context ):
67
+ actual = [type (item ).__name__ for item in context .cell .iter_inner_content ()]
68
+ expected = ["Paragraph" , "Table" , "Paragraph" ]
69
+ assert actual == expected , f"expected: { expected } , got: { actual } "
70
+
71
+
72
+ @then ("document.iter_inner_content() produces the block-items in document order" )
73
+ def then_document_iter_inner_content_produces_the_block_items (context : Context ):
74
+ actual = [type (item ).__name__ for item in context .document .iter_inner_content ()]
75
+ expected = ["Table" , "Paragraph" , "Table" , "Paragraph" , "Table" , "Paragraph" ]
76
+ assert actual == expected , f"expected: { expected } , got: { actual } "
77
+
78
+
79
+ @then ("footer.iter_inner_content() produces the block-items in document order" )
80
+ def then_footer_iter_inner_content_produces_the_block_items (context : Context ):
81
+ actual = [type (item ).__name__ for item in context .footer .iter_inner_content ()]
82
+ expected = ["Paragraph" , "Table" , "Paragraph" ]
83
+ assert actual == expected , f"expected: { expected } , got: { actual } "
84
+
85
+
86
+ @then ("header.iter_inner_content() produces the block-items in document order" )
87
+ def then_header_iter_inner_content_produces_the_block_items (context : Context ):
88
+ actual = [type (item ).__name__ for item in context .header .iter_inner_content ()]
89
+ expected = ["Table" , "Paragraph" ]
90
+ assert actual == expected , f"expected: { expected } , got: { actual } "
91
+
92
+
43
93
@then ("I can access the table" )
44
94
def then_can_access_table (context : Context ):
45
95
table = context .document .tables [- 1 ]
0 commit comments