|
12 | 12 | from docx.enum.text import WD_ALIGN_PARAGRAPH, WD_LINE_SPACING |
13 | 13 | from docx.shared import Pt |
14 | 14 | from docx.text.parfmt import ParagraphFormat |
| 15 | +from docx.text.tabstops import TabStops |
15 | 16 |
|
16 | 17 | import pytest |
17 | 18 |
|
18 | 19 | from ..unitutil.cxml import element, xml |
| 20 | +from ..unitutil.mock import class_mock, instance_mock |
19 | 21 |
|
20 | 22 |
|
21 | 23 | class DescribeParagraphFormat(object): |
@@ -102,6 +104,12 @@ def it_can_change_its_on_off_props(self, on_off_set_fixture): |
102 | 104 | setattr(paragraph_format, prop_name, value) |
103 | 105 | assert paragraph_format._element.xml == expected_xml |
104 | 106 |
|
| 107 | + def it_provides_access_to_its_tab_stops(self, tab_stops_fixture): |
| 108 | + paragraph_format, TabStops_, pPr, tab_stops_ = tab_stops_fixture |
| 109 | + tab_stops = paragraph_format.tab_stops |
| 110 | + TabStops_.assert_called_once_with(pPr) |
| 111 | + assert tab_stops is tab_stops_ |
| 112 | + |
105 | 113 | # fixtures ------------------------------------------------------- |
106 | 114 |
|
107 | 115 | @pytest.fixture(params=[ |
@@ -393,3 +401,22 @@ def space_before_set_fixture(self, request): |
393 | 401 | paragraph_format = ParagraphFormat(element(p_cxml)) |
394 | 402 | expected_xml = xml(expected_p_cxml) |
395 | 403 | return paragraph_format, value, expected_xml |
| 404 | + |
| 405 | + @pytest.fixture |
| 406 | + def tab_stops_fixture(self, TabStops_, tab_stops_): |
| 407 | + p = element('w:p/w:pPr') |
| 408 | + pPr = p.pPr |
| 409 | + paragraph_format = ParagraphFormat(p, None) |
| 410 | + return paragraph_format, TabStops_, pPr, tab_stops_ |
| 411 | + |
| 412 | + # fixture components --------------------------------------------- |
| 413 | + |
| 414 | + @pytest.fixture |
| 415 | + def TabStops_(self, request, tab_stops_): |
| 416 | + return class_mock( |
| 417 | + request, 'docx.text.parfmt.TabStops', return_value=tab_stops_ |
| 418 | + ) |
| 419 | + |
| 420 | + @pytest.fixture |
| 421 | + def tab_stops_(self, request): |
| 422 | + return instance_mock(request, TabStops) |
0 commit comments