Skip to content

Commit 5e191e7

Browse files
author
Steve Canny
committed
acpt: update scenario for Paragraph.clear()
to use new style API
1 parent ef5f164 commit 5e191e7

3 files changed

Lines changed: 4 additions & 19 deletions

File tree

features/par-clear-paragraph.feature

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ Feature: Clear paragraph content
44
I need a way to remove the content of a paragraph
55

66

7-
@wip
87
Scenario: Clear paragraph content
98
Given a paragraph with content and formatting
109
When I clear the paragraph content

features/steps/paragraph.py

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,10 @@
88

99
from docx import Document
1010
from docx.enum.text import WD_ALIGN_PARAGRAPH
11-
from docx.oxml import parse_xml
12-
from docx.oxml.ns import nsdecls
13-
from docx.text.paragraph import Paragraph
1411

1512
from helpers import saved_docx_path, test_docx, test_text
1613

1714

18-
TEST_STYLE = 'Heading1'
19-
20-
2115
# given ===================================================
2216

2317
@given('a document containing three paragraphs')
@@ -56,17 +50,8 @@ def given_a_paragraph_having_style(context, style_state):
5650

5751
@given('a paragraph with content and formatting')
5852
def given_a_paragraph_with_content_and_formatting(context):
59-
p_xml = """\
60-
<w:p %s>
61-
<w:pPr>
62-
<w:pStyle w:val="%s"/>
63-
</w:pPr>
64-
<w:r>
65-
<w:t>foobar</w:t>
66-
</w:r>
67-
</w:p>""" % (nsdecls('w'), TEST_STYLE)
68-
p = parse_xml(p_xml)
69-
context.paragraph = Paragraph(p, None)
53+
document = Document(test_docx('par-known-paragraphs'))
54+
context.paragraph = document.paragraphs[0]
7055

7156

7257
# when ====================================================
@@ -144,7 +129,8 @@ def then_the_paragraph_alignment_prop_value_is_value(context, align_value):
144129

145130
@then('the paragraph formatting is preserved')
146131
def then_the_paragraph_formatting_is_preserved(context):
147-
assert context.paragraph.style == TEST_STYLE
132+
paragraph = context.paragraph
133+
assert paragraph.style.name == 'Heading 1'
148134

149135

150136
@then('the paragraph has no content')
27.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)