Skip to content

Commit 6c3ccd1

Browse files
author
Steve Canny
committed
acpt: add scenario for Style.delete()
1 parent 11efbb7 commit 6c3ccd1

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

features/steps/styles.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ def when_I_call_add_style(context, name, type_str, builtin_str):
7575
styles.add_style(name, type, builtin=builtin)
7676

7777

78+
@when('I delete a style')
79+
def when_I_delete_a_style(context):
80+
context.document.styles['No List'].delete()
81+
82+
7883
# then =====================================================
7984

8085
@then('I can access a style by its UI name')
@@ -157,9 +162,27 @@ def then_styles_name_is_a_style(context, name):
157162
assert isinstance(style, BaseStyle)
158163

159164

165+
@then('the deleted style is not in the styles collection')
166+
def then_the_deleted_style_is_not_in_the_styles_collection(context):
167+
document = context.document
168+
try:
169+
document.styles['No List']
170+
except KeyError:
171+
return
172+
raise AssertionError('Style not deleted')
173+
174+
160175
@then('the document has one additional style')
161176
def then_the_document_has_one_additional_style(context):
162177
document = context.document
163178
style_count = len(document.styles)
164179
expected_style_count = context.style_count + 1
165180
assert style_count == expected_style_count
181+
182+
183+
@then('the document has one fewer styles')
184+
def then_the_document_has_one_fewer_styles(context):
185+
document = context.document
186+
style_count = len(document.styles)
187+
expected_style_count = context.style_count - 1
188+
assert style_count == expected_style_count

features/sty-delete-style.feature

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Feature: Delete a style
2+
In order to customize the available styles in a document
3+
As a developer using python-docx
4+
I need a way to delete a style
5+
6+
7+
@wip
8+
Scenario: Delete a style
9+
Given a document having known styles
10+
When I delete a style
11+
Then the document has one fewer styles
12+
And the deleted style is not in the styles collection

0 commit comments

Comments
 (0)