1111# given ===================================================
1212
1313
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+
1426@given ("a document containing a table" )
1527def given_a_document_containing_a_table (context : Context ):
1628 context .document = Document (test_docx ("blk-containing-table" ))
1729
1830
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+
1941@given ("a paragraph" )
2042def given_a_paragraph (context : Context ):
2143 context .document = Document ()
@@ -40,6 +62,34 @@ def when_add_table(context: Context):
4062# then =====================================================
4163
4264
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+
4393@then ("I can access the table" )
4494def then_can_access_table (context : Context ):
4595 table = context .document .tables [- 1 ]
0 commit comments