|
13 | 13 | from docx.oxml.parts.document import CT_Body
|
14 | 14 | from docx.oxml.text.run import CT_R
|
15 | 15 | from docx.package import ImageParts, Package
|
16 |
| -from docx.parts.document import _Body, DocumentPart, InlineShapes |
| 16 | +from docx.parts.document import DocumentPart, InlineShapes |
17 | 17 | from docx.parts.image import ImagePart
|
18 | 18 | from docx.parts.numbering import NumberingPart
|
19 | 19 | from docx.parts.styles import StylesPart
|
20 | 20 | from docx.shape import InlineShape
|
21 | 21 | from docx.styles.style import BaseStyle
|
22 | 22 | from docx.styles.styles import Styles
|
23 |
| -from docx.table import Table |
24 | 23 | from docx.text.paragraph import Paragraph
|
25 | 24 | from docx.text.run import Run
|
26 | 25 |
|
27 | 26 | from ..oxml.parts.unitdata.document import a_body, a_document
|
28 | 27 | from ..oxml.unitdata.text import a_p
|
29 |
| -from ..unitutil.cxml import element, xml |
| 28 | +from ..unitutil.cxml import element |
30 | 29 | from ..unitutil.mock import (
|
31 | 30 | instance_mock, class_mock, loose_mock, method_mock, property_mock
|
32 | 31 | )
|
@@ -303,92 +302,6 @@ def _styles_part_prop_(self, request):
|
303 | 302 | return property_mock(request, DocumentPart, '_styles_part')
|
304 | 303 |
|
305 | 304 |
|
306 |
| -class Describe_Body(object): |
307 |
| - |
308 |
| - def it_can_add_a_paragraph(self, add_paragraph_fixture): |
309 |
| - body, expected_xml = add_paragraph_fixture |
310 |
| - p = body.add_paragraph() |
311 |
| - assert body._body.xml == expected_xml |
312 |
| - assert isinstance(p, Paragraph) |
313 |
| - |
314 |
| - def it_can_add_a_table(self, add_table_fixture): |
315 |
| - body, rows, cols, expected_xml = add_table_fixture |
316 |
| - table = body.add_table(rows, cols) |
317 |
| - assert body._element.xml == expected_xml |
318 |
| - assert isinstance(table, Table) |
319 |
| - |
320 |
| - def it_can_clear_itself_of_all_content_it_holds(self, clear_fixture): |
321 |
| - body, expected_xml = clear_fixture |
322 |
| - _body = body.clear_content() |
323 |
| - assert body._body.xml == expected_xml |
324 |
| - assert _body is body |
325 |
| - |
326 |
| - def it_provides_access_to_the_paragraphs_it_contains( |
327 |
| - self, paragraphs_fixture): |
328 |
| - body = paragraphs_fixture |
329 |
| - paragraphs = body.paragraphs |
330 |
| - assert len(paragraphs) == 2 |
331 |
| - for p in paragraphs: |
332 |
| - assert isinstance(p, Paragraph) |
333 |
| - |
334 |
| - def it_provides_access_to_the_tables_it_contains(self, tables_fixture): |
335 |
| - body = tables_fixture |
336 |
| - tables = body.tables |
337 |
| - assert len(tables) == 2 |
338 |
| - for table in tables: |
339 |
| - assert isinstance(table, Table) |
340 |
| - |
341 |
| - # fixtures ------------------------------------------------------- |
342 |
| - |
343 |
| - @pytest.fixture(params=[ |
344 |
| - ('w:body', 'w:body/w:p'), |
345 |
| - ('w:body/w:p', 'w:body/(w:p, w:p)'), |
346 |
| - ('w:body/w:sectPr', 'w:body/(w:p, w:sectPr)'), |
347 |
| - ('w:body/(w:p, w:sectPr)', 'w:body/(w:p, w:p, w:sectPr)'), |
348 |
| - ]) |
349 |
| - def add_paragraph_fixture(self, request): |
350 |
| - before_cxml, after_cxml = request.param |
351 |
| - body = _Body(element(before_cxml), None) |
352 |
| - expected_xml = xml(after_cxml) |
353 |
| - return body, expected_xml |
354 |
| - |
355 |
| - @pytest.fixture(params=[ |
356 |
| - ('w:body', 0, 0, 'w:body/w:tbl/(w:tblPr/w:tblW{w:type=auto,w:w=0},w:' |
357 |
| - 'tblGrid)'), |
358 |
| - ('w:body', 1, 0, 'w:body/w:tbl/(w:tblPr/w:tblW{w:type=auto,w:w=0},w:' |
359 |
| - 'tblGrid,w:tr)'), |
360 |
| - ('w:body', 0, 1, 'w:body/w:tbl/(w:tblPr/w:tblW{w:type=auto,w:w=0},w:' |
361 |
| - 'tblGrid/w:gridCol)'), |
362 |
| - ('w:body', 1, 1, 'w:body/w:tbl/(w:tblPr/w:tblW{w:type=auto,w:w=0},w:' |
363 |
| - 'tblGrid/w:gridCol,w:tr/w:tc/w:p)'), |
364 |
| - ]) |
365 |
| - def add_table_fixture(self, request): |
366 |
| - body_cxml, rows, cols, after_cxml = request.param |
367 |
| - body = _Body(element(body_cxml), None) |
368 |
| - expected_xml = xml(after_cxml) |
369 |
| - return body, rows, cols, expected_xml |
370 |
| - |
371 |
| - @pytest.fixture(params=[ |
372 |
| - ('w:body', 'w:body'), |
373 |
| - ('w:body/w:p', 'w:body'), |
374 |
| - ('w:body/w:sectPr', 'w:body/w:sectPr'), |
375 |
| - ('w:body/(w:p, w:sectPr)', 'w:body/w:sectPr'), |
376 |
| - ]) |
377 |
| - def clear_fixture(self, request): |
378 |
| - before_cxml, after_cxml = request.param |
379 |
| - body = _Body(element(before_cxml), None) |
380 |
| - expected_xml = xml(after_cxml) |
381 |
| - return body, expected_xml |
382 |
| - |
383 |
| - @pytest.fixture |
384 |
| - def paragraphs_fixture(self): |
385 |
| - return _Body(element('w:body/(w:p, w:p)'), None) |
386 |
| - |
387 |
| - @pytest.fixture |
388 |
| - def tables_fixture(self): |
389 |
| - return _Body(element('w:body/(w:tbl, w:tbl)'), None) |
390 |
| - |
391 |
| - |
392 | 305 | class DescribeInlineShapes(object):
|
393 | 306 |
|
394 | 307 | def it_knows_how_many_inline_shapes_it_contains(
|
|
0 commit comments