|
29 | 29 |
|
30 | 30 |
|
31 | 31 | class DescribeParagraph(object):
|
| 32 | + def it_can_end_a_bookmark(self, end_bookmark_fixture): |
| 33 | + blockContainer, name, bookmarkStart, expected_xml = end_bookmark_fixture |
| 34 | + |
| 35 | + blkcntnr = Paragraph(blockContainer, None) |
| 36 | + bookmark_ = _Bookmark((bookmarkStart, None)) |
| 37 | + |
| 38 | + bookmark = blkcntnr.end_bookmark(bookmark_) |
| 39 | + |
| 40 | + assert blkcntnr._element.xml == expected_xml |
| 41 | + assert bookmark.name == name |
| 42 | + assert bookmark is bookmark_ |
| 43 | + |
32 | 44 | def it_can_start_a_bookmark(
|
33 | 45 | self,
|
34 | 46 | start_bookmark_fixture,
|
@@ -208,6 +220,30 @@ def clear_fixture(self, request):
|
208 | 220 | expected_xml = xml(expected_cxml)
|
209 | 221 | return paragraph, expected_xml
|
210 | 222 |
|
| 223 | + @pytest.fixture( |
| 224 | + params=[ |
| 225 | + # ---at start of paragraph--- |
| 226 | + ( |
| 227 | + "w:p/(w:bookmarkStart{w:name=bmk-1, w:id=24})", |
| 228 | + "w:bookmarkStart{w:name=bmk-1, w:id=24}", |
| 229 | + "w:p/(w:bookmarkStart{w:name=bmk-1, w:id=24},w:bookmarkEnd{w:id=24})", |
| 230 | + ), |
| 231 | + ( |
| 232 | + # ---run in between bookmarks--- |
| 233 | + 'w:p/(w:bookmarkStart{w:name=bmk-1, w:id=24}, w:r/w:t"foobar")', |
| 234 | + "w:bookmarkStart{w:name=bmk-1, w:id=24}", |
| 235 | + 'w:p/(w:bookmarkStart{w:name=bmk-1, w:id=24},w:r/w:t"foobar", w:bookmarkEnd{w:id=24})', |
| 236 | + ), |
| 237 | + ] |
| 238 | + ) |
| 239 | + def end_bookmark_fixture(self, request): |
| 240 | + cxml, bookmark_cxml, expected_cxml = request.param |
| 241 | + blockContainer = element(cxml) |
| 242 | + bookmarkStart = element(bookmark_cxml) |
| 243 | + expected_xml = xml(expected_cxml) |
| 244 | + name = "bmk-1" |
| 245 | + return blockContainer, name, bookmarkStart, expected_xml |
| 246 | + |
211 | 247 | @pytest.fixture(params=[(None, None), ("Foo", None), (None, "Bar"), ("Foo", "Bar")])
|
212 | 248 | def insert_before_fixture(self, request, _insert_paragraph_before_, add_run_):
|
213 | 249 | text, style = request.param
|
|
0 commit comments