File tree Expand file tree Collapse file tree 3 files changed +27
-2
lines changed
Expand file tree Collapse file tree 3 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -60,9 +60,9 @@ class Run(object):
6060 """
6161 Proxy object wrapping ``<w:r>`` element.
6262 """
63- def __init__ (self , r_elm ):
63+ def __init__ (self , r ):
6464 super (Run , self ).__init__ ()
65- self ._r = r_elm
65+ self ._r = r
6666
6767 def add_break (self , break_type = WD_BREAK .LINE ):
6868 """
Original file line number Diff line number Diff line change 1+ Feature : Add a page break
2+ 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
5+
6+ @wip
7+ Scenario : Add a hard page break paragraph
8+ Given a document
9+ When I add a page break to the document
10+ Then the last paragraph contains only a page break
Original file line number Diff line number Diff line change @@ -27,6 +27,12 @@ def when_add_heading_specifying_only_its_text(context):
2727 document .add_heading (context .heading_text )
2828
2929
30+ @when ('I add a page break to the document' )
31+ def when_add_page_break_to_document (context ):
32+ document = context .document
33+ document .add_page_break ()
34+
35+
3036@when ('I add a paragraph specifying its style' )
3137def when_add_paragraph_specifying_style (context ):
3238 document = context .document
@@ -80,6 +86,15 @@ def when_add_picture_specifying_only_image_file(context):
8086
8187# then =====================================================
8288
89+ @then ('the last paragraph contains only a page break' )
90+ def then_last_paragraph_contains_only_a_page_break (context ):
91+ document = context .document
92+ p = document .paragraphs [- 1 ]
93+ assert len (p .runs ) == 1
94+ assert len (p .runs [0 ]) == 1
95+ assert p .runs [0 ]._r [0 ].type == 'page'
96+
97+
8398@then ('the last paragraph contains the heading text' )
8499def then_last_p_contains_heading_text (context ):
85100 document = context .document
You can’t perform that action at this time.
0 commit comments