@@ -175,6 +175,18 @@ def it_provides_access_to_the_paragraphs_it_contains(
175
175
count += 1
176
176
assert count == 2
177
177
178
+ def it_provides_access_to_the_tables_it_contains (self , tables_fixture ):
179
+ # test len(), iterable, and indexed access
180
+ cell , expected_count = tables_fixture
181
+ tables = cell .tables
182
+ assert len (tables ) == expected_count
183
+ count = 0
184
+ for idx , table in enumerate (tables ):
185
+ assert isinstance (table , Table )
186
+ assert tables [idx ] is table
187
+ count += 1
188
+ assert count == expected_count
189
+
178
190
def it_can_replace_its_content_with_a_string_of_text (
179
191
self , text_set_fixture ):
180
192
cell , text , expected_xml = text_set_fixture
@@ -223,6 +235,18 @@ def add_table_fixture(self, request):
223
235
def paragraphs_fixture (self ):
224
236
return _Cell (element ('w:tc/(w:p, w:p)' ), None )
225
237
238
+ @pytest .fixture (params = [
239
+ ('w:tc' , 0 ),
240
+ ('w:tc/w:tbl' , 1 ),
241
+ ('w:tc/(w:tbl,w:tbl)' , 2 ),
242
+ ('w:tc/(w:p,w:tbl)' , 1 ),
243
+ ('w:tc/(w:tbl,w:tbl,w:p)' , 2 ),
244
+ ])
245
+ def tables_fixture (self , request ):
246
+ cell_cxml , expected_count = request .param
247
+ cell = _Cell (element (cell_cxml ), None )
248
+ return cell , expected_count
249
+
226
250
@pytest .fixture (params = [
227
251
('w:tc/w:p' , 'foobar' ,
228
252
'w:tc/w:p/w:r/w:t"foobar"' ),
0 commit comments