Skip to content

Commit 3ab7ad1

Browse files
author
Steve Canny
committed
acpt: add api-add-paragraph.feature
1 parent ad99e19 commit 3ab7ad1

File tree

3 files changed

+55
-9
lines changed

3 files changed

+55
-9
lines changed

features/api-add-paragraph.feature

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Feature: Add a paragraph with optional text and style
2+
In order to populate the text of a document
3+
As a programmer using the basic python-docx API
4+
I want to add a styled paragraph of text in a single step
5+
6+
@wip
7+
Scenario: Add an empty paragraph
8+
Given a document
9+
When I add a paragraph without specifying text or style
10+
Then the last paragraph is the empty paragraph I added
11+
12+
@wip
13+
Scenario: Add a paragraph specifying its text
14+
Given a document
15+
When I add a paragraph spefifying its text
16+
Then the last paragraph contains the text I specified
17+
18+
@wip
19+
Scenario: Add a paragraph specifying its style
20+
Given a document
21+
When I add a paragraph spefifying its style
22+
Then the style of the last paragraph is the style I specified

features/blk-add-paragraph.feature

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
Feature: Add a paragraph of text
2-
In order to add text to a document
2+
In order to populate the text of a document
33
As an python-docx developer
4-
I need to add a paragraph
4+
I need the ability to add a paragraph
55

6-
Scenario: Add a paragraph
7-
Given a document
8-
When I add a paragraph
9-
And I add a run to the paragraph
10-
And I add text to the run
11-
And I save the document
12-
Then the document contains the text I added
6+
Scenario: Add a paragraph using low-level text API
7+
Given a document
8+
When I add a paragraph
9+
And I add a run to the paragraph
10+
And I add text to the run
11+
And I save the document
12+
Then the document contains the text I added

features/steps/api.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# encoding: utf-8
2+
3+
"""
4+
Step implementations for top-level features
5+
"""
6+
7+
from behave import then, when
8+
9+
10+
# when ====================================================
11+
12+
@when('I add a paragraph without specifying text or style')
13+
def step_when_add_paragraph_without_specifying_text_or_style(context):
14+
document = context.document
15+
document.add_paragraph()
16+
17+
18+
# then =====================================================
19+
20+
@then('the last paragraph is the empty paragraph I added')
21+
def step_then_document_contains_text_I_added(context):
22+
document = context.document
23+
p = document.paragraphs[-1]
24+
assert p.text == ''

0 commit comments

Comments
 (0)