Skip to content

Commit dc793d3

Browse files
committed
acpt: add scenario for Document.end_bookmark()
1 parent 19c38e5 commit dc793d3

3 files changed

Lines changed: 29 additions & 4 deletions

File tree

docx/document.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ def core_properties(self):
112112
"""
113113
return self._part.core_properties
114114

115+
def end_bookmark(self, bookmark):
116+
"""Return `bookmark` after closing it at end of this document."""
117+
raise NotImplementedError
118+
115119
@property
116120
def inline_shapes(self):
117121
"""

features/doc-document.feature

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,10 @@ Feature: Document properties and methods
88
When I assign bookmark = document.start_bookmark("Target")
99
Then bookmark.name == "Target"
1010
And bookmark.id is an int
11+
12+
@wip
13+
Scenario: Document.end_bookmark()
14+
Given a Document object as document
15+
And an open Bookmark object named "Target" as bookmark
16+
Then bookmark == document.end_bookmark(bookmark)
17+
And bookmark == document.bookmarks.get("Target")

features/steps/document.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
# encoding: utf-8
22

3-
"""
4-
Step implementations for document-related features
5-
"""
3+
"""Step implementations for document-related features"""
64

7-
from __future__ import absolute_import, print_function, unicode_literals
5+
from __future__ import absolute_import, division, print_function, unicode_literals
86

97
from behave import given, then, when
108

@@ -70,6 +68,11 @@ def given_a_single_section_Document_object_with_headers_and_footers(context):
7068
context.document = Document(test_docx("doc-add-section"))
7169

7270

71+
@given('an open Bookmark object named "Target" as bookmark')
72+
def given_an_open_Bookmark_object_named_Target_as_bookmark(context):
73+
context.bookmark = context.document.start_bookmark("Target")
74+
75+
7376
# when ====================================================
7477

7578

@@ -182,6 +185,17 @@ def when_I_execute_section_eq_document_add_section(context):
182185
# then ====================================================
183186

184187

188+
@then('bookmark == document.bookmarks.get("Target")')
189+
def then_bookmark_eq_document_bookmarks_get_Target(context):
190+
assert context.bookmark == context.document.bookmarks.get("Target")
191+
192+
193+
@then("bookmark == document.end_bookmark(bookmark)")
194+
def then_bookmark_eq_document_end_bookmark(context):
195+
bookmark = context.bookmark
196+
assert bookmark == context.document.end_bookmark(bookmark)
197+
198+
185199
@then("document.bookmarks is a Bookmarks object")
186200
def then_document_bookmarks_is_a_Bookmarks_object(context):
187201
actual = context.document.bookmarks.__class__.__name__

0 commit comments

Comments
 (0)