Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bcd4a55

Browse files
DKWoodsSteve Canny
authored andcommitted
acpt: add scenarios for TabStop property setters
1 parent 321cad1 commit bcd4a55

File tree

2 files changed

+65
-1
lines changed

2 files changed

+65
-1
lines changed

features/steps/tabstops.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Step implementations for paragraph-related features
55
"""
66

7-
from behave import given, then
7+
from behave import given, then, when
88

99
from docx import Document
1010
from docx.enum.text import WD_TAB_ALIGNMENT, WD_TAB_LEADER
@@ -28,6 +28,7 @@ def given_a_tab_stop_inches_from_paragraph_left_edge(context, in_or_out):
2828
tab_idx = {'out': 0, 'in': 1}[in_or_out]
2929
document = Document(test_docx('tab-stops'))
3030
paragraph_format = document.paragraphs[2].paragraph_format
31+
context.tab_stops = paragraph_format.tab_stops
3132
context.tab_stop = paragraph_format.tab_stops[tab_idx]
3233

3334

@@ -47,6 +48,25 @@ def given_a_tab_stop_having_leader_leader(context, leader):
4748
context.tab_stop = paragraph_format.tab_stops[tab_idx]
4849

4950

51+
# when ====================================================
52+
53+
@when('I assign {member} to tab_stop.alignment')
54+
def when_I_assign_member_to_tab_stop_alignment(context, member):
55+
value = getattr(WD_TAB_ALIGNMENT, member)
56+
context.tab_stop.alignment = value
57+
58+
59+
@when('I assign {member} to tab_stop.leader')
60+
def when_I_assign_member_to_tab_stop_leader(context, member):
61+
value = getattr(WD_TAB_LEADER, member)
62+
context.tab_stop.leader = value
63+
64+
65+
@when('I assign {value} to tab_stop.position')
66+
def when_I_assign_value_to_tab_stop_value(context, value):
67+
context.tab_stop.position = int(value)
68+
69+
5070
# then =====================================================
5171

5272
@then('I can access a tab stop by index')
@@ -88,3 +108,10 @@ def then_tab_stop_leader_is_leader(context, leader):
88108
def then_tab_stop_position_is_position(context, position):
89109
tab_stop = context.tab_stop
90110
assert tab_stop.position == int(position)
111+
112+
113+
@then('the tab stops are sequenced in position order')
114+
def then_the_tab_stops_are_sequenced_in_position_order(context):
115+
tab_stops = context.tab_stops
116+
for idx in range(len(tab_stops) - 1):
117+
assert tab_stops[idx].position < tab_stops[idx+1].position

features/tab-tabstop-props.feature

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,19 @@ Feature: Tab stop properties
1414
| out | -457200 |
1515

1616

17+
@wip
18+
Scenario Outline: Set TabStop.position
19+
Given a tab stop 0.5 inches in from the paragraph left edge
20+
When I assign <value> to tab_stop.position
21+
Then tab_stop.position is <value>
22+
And the tab stops are sequenced in position order
23+
24+
Examples: tab stop positions
25+
| value |
26+
| 228600 |
27+
| -914400 |
28+
29+
1730
Scenario Outline: Get TabStop.alignment
1831
Given a tab stop having <alignment> alignment
1932
Then tab_stop.alignment is <alignment>
@@ -24,6 +37,18 @@ Feature: Tab stop properties
2437
| RIGHT |
2538

2639

40+
@wip
41+
Scenario Outline: Set TabStop.alignment
42+
Given a tab stop having <alignment> alignment
43+
When I assign <member> to tab_stop.alignment
44+
Then tab_stop.alignment is <member>
45+
46+
Examples: tab stop alignments
47+
| alignment | member |
48+
| LEFT | CENTER |
49+
| RIGHT | LEFT |
50+
51+
2752
Scenario Outline: Get TabStop.leader
2853
Given a tab stop having <leader> leader
2954
Then tab_stop.leader is <value>
@@ -32,3 +57,15 @@ Feature: Tab stop properties
3257
| leader | value |
3358
| no specified | SPACES |
3459
| a dotted | DOTS |
60+
61+
62+
@wip
63+
Scenario Outline: Set TabStop.leader
64+
Given a tab stop having <leader> leader
65+
When I assign <member> to tab_stop.leader
66+
Then tab_stop.leader is <member>
67+
68+
Examples: tab stop leaders
69+
| leader | member |
70+
| no specified | DOTS |
71+
| a dotted | SPACES |

0 commit comments

Comments
 (0)