Skip to content

Commit b8e3de8

Browse files
DKWoodsSteve Canny
authored and
Steve Canny
committed
acpt: add scenario for ParagraphFormat.tab_stops
1 parent d33255c commit b8e3de8

File tree

4 files changed

+39
-0
lines changed

4 files changed

+39
-0
lines changed

docx/text/tabstops.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# encoding: utf-8
2+
3+
"""
4+
Tabstop-related proxy types.
5+
"""
6+
7+
from __future__ import (
8+
absolute_import, division, print_function, unicode_literals
9+
)
10+
11+
from ..shared import ElementProxy
12+
13+
14+
class TabStops(ElementProxy):
15+
"""
16+
A sequence providing access to the tab stops of a paragraph or paragraph
17+
style. Supports iteration, indexed access, del, and len(). It is accesed
18+
using the `tab_stops` property of ParagraphFormat; it is not intended to
19+
be constructed directly.
20+
"""

features/steps/parfmt.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,19 @@
1313
from docx import Document
1414
from docx.enum.text import WD_ALIGN_PARAGRAPH, WD_LINE_SPACING
1515
from docx.shared import Pt
16+
from docx.text.tabstops import TabStops
1617

1718
from helpers import test_docx
1819

1920

2021
# given ===================================================
2122

23+
@given('a paragraph format')
24+
def given_a_paragraph_format(context):
25+
document = Document(test_docx('tab-stops'))
26+
context.paragraph_format = document.paragraphs[0].paragraph_format
27+
28+
2229
@given('a paragraph format having {prop_name} set {setting}')
2330
def given_a_paragraph_format_having_prop_set(context, prop_name, setting):
2431
style_name = {
@@ -139,6 +146,12 @@ def when_I_assign_value_to_paragraph_format_prop(context, value, prop_name):
139146

140147
# then =====================================================
141148

149+
@then('paragraph_format.tab_stops is a TabStops object')
150+
def then_paragraph_format_tab_stops_is_a_tabstops_object(context):
151+
tab_stops = context.paragraph_format.tab_stops
152+
assert isinstance(tab_stops, TabStops)
153+
154+
142155
@then('paragraph_format.alignment is {value}')
143156
def then_paragraph_format_alignment_is_value(context, value):
144157
expected_value = {
12.5 KB
Binary file not shown.

features/txt-parfmt-props.feature

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ Feature: Get or set paragraph formatting properties
44
I need a ParagraphFormat object with read/write formatting properties
55

66

7+
@wip
8+
Scenario: Get tab stops
9+
Given a paragraph format
10+
Then paragraph_format.tab_stops is a TabStops object
11+
12+
713
Scenario Outline: Get paragraph alignment
814
Given a paragraph format having <align-type> alignment
915
Then paragraph_format.alignment is <value>

0 commit comments

Comments
 (0)