Skip to content

Commit 97b2e62

Browse files
author
Steve Canny
committed
acpt: add par-set-text.feature
with scenario for Paragraph.text setter
1 parent 70b580e commit 97b2e62

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

features/par-set-text.feature

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Feature: Replace paragraph text
2+
In order to conveniently change the text of a paragraph in place
3+
As a developer using python-docx
4+
I need a writable text property on paragraph
5+
6+
7+
@wip
8+
Scenario: Set paragraph text
9+
Given a paragraph with content and formatting
10+
When I set the paragraph text
11+
Then the paragraph has the text I set
12+
And the paragraph formatting is preserved

features/steps/paragraph.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ def when_I_set_the_paragraph_style(context):
6767
context.paragraph.style = TEST_STYLE
6868

6969

70+
@when('I set the paragraph text')
71+
def when_I_set_the_paragraph_text(context):
72+
context.paragraph.text = 'bar\tfoo\r'
73+
74+
7075
# then =====================================================
7176

7277
@then('the document contains four paragraphs')
@@ -99,6 +104,11 @@ def then_the_paragraph_has_the_style_I_set(context):
99104
assert paragraph.style == TEST_STYLE
100105

101106

107+
@then('the paragraph has the text I set')
108+
def then_the_paragraph_has_the_text_I_set(context):
109+
assert context.paragraph.text == 'bar\tfoo\n'
110+
111+
102112
@then('the style of the second paragraph matches the style I set')
103113
def then_the_style_of_the_second_paragraph_matches_the_style_I_set(context):
104114
second_paragraph = context.document.paragraphs[1]

0 commit comments

Comments
 (0)