1212
1313from mock import Mock
1414
15+ from docx .table import Table
1516from docx .text import Paragraph
1617
1718from .oxml .unitdata .parts import a_body
19+ from .oxml .unitdata .table import a_tbl
1820from .oxml .unitdata .text import a_p , a_sectPr
1921from .unitutil import class_mock , function_mock , initializer_mock
2022
@@ -90,7 +92,6 @@ def it_can_clear_itself_of_all_content_it_holds(
9092 body , expected_xml = clear_content_fixture
9193 _body = body .clear_content ()
9294 assert body ._body .xml == expected_xml
93- print (body ._body .xml )
9495 assert _body is body
9596
9697 def it_provides_access_to_the_paragraphs_it_contains (
@@ -101,6 +102,14 @@ def it_provides_access_to_the_paragraphs_it_contains(
101102 for p in paragraphs :
102103 assert isinstance (p , Paragraph )
103104
105+ def it_provides_access_to_the_tables_it_contains (
106+ self , body_with_tables ):
107+ body = body_with_tables
108+ tables = body .tables
109+ assert len (tables ) == 2
110+ for table in tables :
111+ assert isinstance (table , Table )
112+
104113 # fixtures -------------------------------------------------------
105114
106115 @pytest .fixture (params = [
@@ -136,6 +145,16 @@ def body_with_paragraphs(self):
136145 )
137146 return _Body (body_elm )
138147
148+ @pytest .fixture
149+ def body_with_tables (self ):
150+ body_elm = (
151+ a_body ().with_nsdecls ()
152+ .with_child (a_tbl ())
153+ .with_child (a_tbl ())
154+ .element
155+ )
156+ return _Body (body_elm )
157+
139158 @pytest .fixture (params = [False , True ])
140159 def clear_content_fixture (self , request ):
141160 has_sectPr = request .param
0 commit comments