Skip to content

Commit 4f0c322

Browse files
author
Steve Canny
committed
acpt: add scenarios for Document.settings
1 parent b1d0771 commit 4f0c322

File tree

5 files changed

+71
-2
lines changed

5 files changed

+71
-2
lines changed

docx/settings.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# encoding: utf-8
2+
3+
"""
4+
Settings object, providing access to document-level settings.
5+
"""
6+
7+
from __future__ import (
8+
absolute_import, division, print_function, unicode_literals
9+
)
10+
11+
from .shared import ElementProxy
12+
13+
14+
class Settings(ElementProxy):
15+
"""
16+
Provides access to document-level settings for a document. Accessed using
17+
the :attr:`.Document.settings` property.
18+
"""
19+
20+
__slots__ = ()

features/doc-settings.feature

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Feature: Access to document settings
2+
In order to operate on document-level settings
3+
As a developer using python-docx
4+
I access to settings stored in the settings part
5+
6+
7+
@wip
8+
Scenario Outline: Access document settings
9+
Given a document having <a-or-no> settings part
10+
Then document.settings is a Settings object
11+
12+
Examples: having a settings part or not
13+
| a-or-no |
14+
| a |
15+
| no |

features/doc-styles.feature

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,3 @@ Feature: Access a document style
1515
| styles-state | style-count |
1616
| a styles part | 6 |
1717
| no styles part | 4 |
18-
19-

features/steps/settings.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# encoding: utf-8
2+
3+
"""
4+
Step implementations for document settings-related features
5+
"""
6+
7+
from __future__ import (
8+
absolute_import, division, print_function, unicode_literals
9+
)
10+
11+
from behave import given, then
12+
13+
from docx import Document
14+
from docx.settings import Settings
15+
16+
from helpers import test_docx
17+
18+
19+
# given ====================================================
20+
21+
@given('a document having a settings part')
22+
def given_a_document_having_a_settings_part(context):
23+
context.document = Document(test_docx('doc-word-default-blank'))
24+
25+
26+
@given('a document having no settings part')
27+
def given_a_document_having_no_settings_part(context):
28+
context.document = Document(test_docx('set-no-settings-part'))
29+
30+
31+
# then =====================================================
32+
33+
@then('document.settings is a Settings object')
34+
def then_document_settings_is_a_Settings_object(context):
35+
document = context.document
36+
assert type(document.settings) is Settings
Binary file not shown.

0 commit comments

Comments
 (0)