File tree 3 files changed +41
-0
lines changed 3 files changed +41
-0
lines changed Original file line number Diff line number Diff line change
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__ = ()
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change 10
10
11
11
from docx import Document
12
12
from docx .enum .section import WD_ORIENT , WD_SECTION
13
+ from docx .header import Header
13
14
from docx .section import Section
14
15
from docx .shared import Inches
15
16
18
19
19
20
# given ====================================================
20
21
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
+
21
28
@given ('a section collection containing 3 sections' )
22
29
def given_a_section_collection_containing_3_sections (context ):
23
30
document = Document (test_docx ('doc-access-sections' ))
@@ -137,6 +144,12 @@ def then_len_sections_is_3(context):
137
144
)
138
145
139
146
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
+
140
153
@then ('the reported {margin_side} margin is {inches} inches' )
141
154
def then_the_reported_margin_is_inches (context , margin_side , inches ):
142
155
prop_name = {
You can’t perform that action at this time.
0 commit comments