Skip to content

Commit 57d67eb

Browse files
author
Steve Canny
committed
acpt: migrate doc-add-page-break.feature
1 parent 3a9523a commit 57d67eb

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
Feature: Add a page break
22
In order to force a page break at a particular location
3-
As a programmer using the basic python-docx API
4-
I need a method that adds a hard page break on its own paragraph
3+
As a developer using the python-docx
4+
I need a way to add a hard page break on its own paragraph
5+
56

67
Scenario: Add a hard page break paragraph
7-
Given a document
8+
Given a blank document
89
When I add a page break to the document
910
Then the last paragraph contains only a page break

features/steps/api.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,6 @@ def when_add_2x2_table_specifying_style_name(context, style_name):
3636
document.add_table(rows=2, cols=2, style=style_name)
3737

3838

39-
@when('I add a page break to the document')
40-
def when_add_page_break_to_document(context):
41-
document = context.document
42-
document.add_page_break()
43-
44-
4539
@when('I add a picture specifying 1.75" width and 2.5" height')
4640
def when_add_picture_specifying_width_and_height(context):
4741
document = context.document
@@ -101,15 +95,6 @@ def then_document_contains_2x2_table(context):
10195
context.table_ = table
10296

10397

104-
@then('the last paragraph contains only a page break')
105-
def then_last_paragraph_contains_only_a_page_break(context):
106-
document = context.document
107-
p = document.paragraphs[-1]
108-
assert len(p.runs) == 1
109-
assert len(p.runs[0]._r) == 1
110-
assert p.runs[0]._r[0].type == 'page'
111-
112-
11398
@then('the last paragraph contains the text I specified')
11499
def then_last_p_contains_specified_text(context):
115100
document = context.document

features/steps/document.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ def when_add_heading_specifying_only_its_text(context):
5555
document.add_heading(text)
5656

5757

58+
@when('I add a page break to the document')
59+
def when_add_page_break_to_document(context):
60+
document = context.document
61+
document.add_page_break()
62+
63+
5864
@when('I add a paragraph specifying its style as a {kind}')
5965
def when_I_add_a_paragraph_specifying_its_style_as_a(context, kind):
6066
document = context.document
@@ -134,6 +140,15 @@ def then_the_first_section_is_portrait(context):
134140
assert first_section.page_height == expected_height
135141

136142

143+
@then('the last paragraph contains only a page break')
144+
def then_last_paragraph_contains_only_a_page_break(context):
145+
document = context.document
146+
paragraph = document.paragraphs[-1]
147+
assert len(paragraph.runs) == 1
148+
assert len(paragraph.runs[0]._r) == 1
149+
assert paragraph.runs[0]._r[0].type == 'page'
150+
151+
137152
@then('the last paragraph contains the heading text')
138153
def then_last_p_contains_heading_text(context):
139154
document = context.document

0 commit comments

Comments
 (0)