|
1 | 1 | """Unit test suite for the docx.text.paragraph module.""" |
2 | 2 |
|
| 3 | +from typing import cast |
| 4 | + |
3 | 5 | import pytest |
4 | 6 |
|
| 7 | +from docx import types as t |
5 | 8 | from docx.enum.style import WD_STYLE_TYPE |
6 | 9 | from docx.enum.text import WD_ALIGN_PARAGRAPH |
7 | 10 | from docx.oxml.text.paragraph import CT_P |
|
16 | 19 |
|
17 | 20 |
|
18 | 21 | class DescribeParagraph(object): |
| 22 | + """Unit-test suite for `docx.text.run.Paragraph`.""" |
| 23 | + |
| 24 | + @pytest.mark.parametrize( |
| 25 | + ("p_cxml", "expected_value"), |
| 26 | + [ |
| 27 | + ("w:p/w:r", False), |
| 28 | + ('w:p/w:r/w:t"foobar"', False), |
| 29 | + ('w:p/w:hyperlink/w:r/(w:t"abc",w:lastRenderedPageBreak,w:t"def")', True), |
| 30 | + ("w:p/w:r/(w:lastRenderedPageBreak, w:lastRenderedPageBreak)", True), |
| 31 | + ], |
| 32 | + ) |
| 33 | + def it_knows_whether_it_contains_a_page_break( |
| 34 | + self, p_cxml: str, expected_value: bool, fake_parent: t.StoryChild |
| 35 | + ): |
| 36 | + p = cast(CT_P, element(p_cxml)) |
| 37 | + paragraph = Paragraph(p, fake_parent) |
| 38 | + |
| 39 | + assert paragraph.contains_page_break == expected_value |
| 40 | + |
19 | 41 | def it_knows_its_paragraph_style(self, style_get_fixture): |
20 | 42 | paragraph, style_id_, style_ = style_get_fixture |
21 | 43 | style = paragraph.style |
|
0 commit comments