66
77import pytest
88
9+ from docx .bookmark import Bookmarks
910from docx .document import _Body , Document
1011from docx .enum .section import WD_SECTION
1112from docx .enum .text import WD_BREAK
@@ -93,6 +94,16 @@ def it_can_save_the_document_to_a_file(self, save_fixture):
9394 document .save (file_ )
9495 document ._part .save .assert_called_once_with (file_ )
9596
97+ def it_provides_access_to_its_bookmarks (
98+ self , document_part_ , Bookmarks_ , bookmarks_ ):
99+ Bookmarks_ .return_value = bookmarks_
100+ document = Document (None , document_part_ )
101+
102+ bookmarks = document .bookmarks
103+
104+ Bookmarks_ .assert_called_once_with (document_part_ )
105+ assert bookmarks is bookmarks_
106+
96107 def it_provides_access_to_its_core_properties (self , core_props_fixture ):
97108 document , core_properties_ = core_props_fixture
98109 core_properties = document .core_properties
@@ -272,6 +283,10 @@ def tables_fixture(self, body_prop_, tables_):
272283 def add_paragraph_ (self , request ):
273284 return method_mock (request , Document , 'add_paragraph' )
274285
286+ @pytest .fixture
287+ def _block_width_prop_ (self , request ):
288+ return property_mock (request , Document , '_block_width' )
289+
275290 @pytest .fixture
276291 def _Body_ (self , request , body_ ):
277292 return class_mock (request , 'docx.document._Body' , return_value = body_ )
@@ -281,12 +296,16 @@ def body_(self, request):
281296 return instance_mock (request , _Body )
282297
283298 @pytest .fixture
284- def _block_width_prop_ (self , request ):
285- return property_mock (request , Document , '_block_width ' )
299+ def body_prop_ (self , request , body_ ):
300+ return property_mock (request , Document , '_body ' )
286301
287302 @pytest .fixture
288- def body_prop_ (self , request , body_ ):
289- return property_mock (request , Document , '_body' , return_value = body_ )
303+ def Bookmarks_ (self , request ):
304+ return class_mock (request , 'docx.document.Bookmarks' )
305+
306+ @pytest .fixture
307+ def bookmarks_ (self , request ):
308+ return instance_mock (request , Bookmarks )
290309
291310 @pytest .fixture
292311 def core_properties_ (self , request ):
0 commit comments