Skip to content

Commit bbbc287

Browse files
eupharisSteve Canny
authored and
Steve Canny
committed
acpt: add scenario for default header access
1 parent 13dd6f0 commit bbbc287

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

docx/header.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# encoding: utf-8
2+
3+
"""
4+
Page headers and footers.
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 Header(ElementProxy):
15+
"""
16+
The default page header of a section.
17+
"""
18+
19+
__slots__ = ()

features/sct-access-header.feature

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Feature: Access section headers and footers
2+
In order to operate on the headers or footers of a section
3+
As a developer using python-docx
4+
I need access to the section headers and footers
5+
6+
@wip
7+
Scenario: Access default header of section
8+
Given a section
9+
Then section.header is a Header object

features/steps/section.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
from docx import Document
1212
from docx.enum.section import WD_ORIENT, WD_SECTION
13+
from docx.header import Header
1314
from docx.section import Section
1415
from docx.shared import Inches
1516

@@ -18,6 +19,12 @@
1819

1920
# given ====================================================
2021

22+
@given('a section')
23+
def given_a_section(context):
24+
document = Document(test_docx('sct-section-props'))
25+
context.section = document.sections[0]
26+
27+
2128
@given('a section collection containing 3 sections')
2229
def given_a_section_collection_containing_3_sections(context):
2330
document = Document(test_docx('doc-access-sections'))
@@ -137,6 +144,12 @@ def then_len_sections_is_3(context):
137144
)
138145

139146

147+
@then('section.header is a Header object')
148+
def then_section_header_is_a_Header_object(context):
149+
section = context.section
150+
assert isinstance(section.header, Header)
151+
152+
140153
@then('the reported {margin_side} margin is {inches} inches')
141154
def then_the_reported_margin_is_inches(context, margin_side, inches):
142155
prop_name = {

0 commit comments

Comments
 (0)