@@ -23,43 +23,55 @@ def it_knows_how_many_sections_it_contains(self):
2323 )
2424 assert len (sections ) == 2
2525
26- def it_can_iterate_over_its_Section_instances (self , Section_ , section_ ):
26+ def it_can_iterate_over_its_Section_instances (
27+ self , Section_ , section_ , document_part_
28+ ):
2729 document_elm = element ("w:document/w:body/(w:p/w:pPr/w:sectPr, w:sectPr)" )
2830 sectPrs = document_elm .xpath ("//w:sectPr" )
2931 Section_ .return_value = section_
30- sections = Sections (document_elm , None )
32+ sections = Sections (document_elm , document_part_ )
3133
3234 section_lst = [s for s in sections ]
3335
34- assert Section_ .call_args_list == [call (sectPrs [0 ]), call (sectPrs [1 ])]
36+ assert Section_ .call_args_list == [
37+ call (sectPrs [0 ], document_part_ ), call (sectPrs [1 ], document_part_ )
38+ ]
3539 assert section_lst == [section_ , section_ ]
3640
37- def it_can_access_its_Section_instances_by_index (self , Section_ , section_ ):
41+ def it_can_access_its_Section_instances_by_index (
42+ self , Section_ , section_ , document_part_
43+ ):
3844 document_elm = element (
3945 "w:document/w:body/(w:p/w:pPr/w:sectPr,w:p/w:pPr/w:sectPr,w:sectPr)"
4046 )
4147 sectPrs = document_elm .xpath ("//w:sectPr" )
4248 Section_ .return_value = section_
43- sections = Sections (document_elm , None )
49+ sections = Sections (document_elm , document_part_ )
4450
4551 section_lst = [sections [idx ] for idx in range (3 )]
4652
4753 assert Section_ .call_args_list == [
48- call (sectPrs [0 ]), call (sectPrs [1 ]), call (sectPrs [2 ])
54+ call (sectPrs [0 ], document_part_ ),
55+ call (sectPrs [1 ], document_part_ ),
56+ call (sectPrs [2 ], document_part_ ),
4957 ]
5058 assert section_lst == [section_ , section_ , section_ ]
5159
52- def it_can_access_its_Section_instances_by_slice (self , Section_ , section_ ):
60+ def it_can_access_its_Section_instances_by_slice (
61+ self , Section_ , section_ , document_part_
62+ ):
5363 document_elm = element (
5464 "w:document/w:body/(w:p/w:pPr/w:sectPr,w:p/w:pPr/w:sectPr,w:sectPr)"
5565 )
5666 sectPrs = document_elm .xpath ("//w:sectPr" )
5767 Section_ .return_value = section_
58- sections = Sections (document_elm , None )
68+ sections = Sections (document_elm , document_part_ )
5969
6070 section_lst = sections [1 :9 ]
6171
62- assert Section_ .call_args_list == [call (sectPrs [1 ]), call (sectPrs [2 ])]
72+ assert Section_ .call_args_list == [
73+ call (sectPrs [1 ], document_part_ ), call (sectPrs [2 ], document_part_ )
74+ ]
6375 assert section_lst == [section_ , section_ ]
6476
6577 # fixture components ---------------------------------------------
@@ -80,51 +92,83 @@ def section_(self, request):
8092class DescribeSection (object ):
8193
8294 def it_knows_its_start_type (self , start_type_get_fixture ):
83- section , expected_start_type = start_type_get_fixture
84- assert section .start_type is expected_start_type
95+ sectPr , expected_start_type = start_type_get_fixture
96+ section = Section (sectPr , None )
97+
98+ start_type = section .start_type
99+
100+ assert start_type is expected_start_type
85101
86102 def it_can_change_its_start_type (self , start_type_set_fixture ):
87- section , new_start_type , expected_xml = start_type_set_fixture
103+ sectPr , new_start_type , expected_xml = start_type_set_fixture
104+ section = Section (sectPr , None )
105+
88106 section .start_type = new_start_type
107+
89108 assert section ._sectPr .xml == expected_xml
90109
91110 def it_knows_its_page_width (self , page_width_get_fixture ):
92- section , expected_page_width = page_width_get_fixture
93- assert section .page_width == expected_page_width
111+ sectPr , expected_page_width = page_width_get_fixture
112+ section = Section (sectPr , None )
113+
114+ page_width = section .page_width
115+
116+ assert page_width == expected_page_width
94117
95118 def it_can_change_its_page_width (self , page_width_set_fixture ):
96- section , new_page_width , expected_xml = page_width_set_fixture
119+ sectPr , new_page_width , expected_xml = page_width_set_fixture
120+ section = Section (sectPr , None )
121+
97122 section .page_width = new_page_width
123+
98124 assert section ._sectPr .xml == expected_xml
99125
100126 def it_knows_its_page_height (self , page_height_get_fixture ):
101- section , expected_page_height = page_height_get_fixture
102- assert section .page_height == expected_page_height
127+ sectPr , expected_page_height = page_height_get_fixture
128+ section = Section (sectPr , None )
129+
130+ page_height = section .page_height
131+
132+ assert page_height == expected_page_height
103133
104134 def it_can_change_its_page_height (self , page_height_set_fixture ):
105- section , new_page_height , expected_xml = page_height_set_fixture
135+ sectPr , new_page_height , expected_xml = page_height_set_fixture
136+ section = Section (sectPr , None )
137+
106138 section .page_height = new_page_height
139+
107140 assert section ._sectPr .xml == expected_xml
108141
109142 def it_knows_its_page_orientation (self , orientation_get_fixture ):
110- section , expected_orientation = orientation_get_fixture
111- assert section .orientation is expected_orientation
143+ sectPr , expected_orientation = orientation_get_fixture
144+ section = Section (sectPr , None )
145+
146+ orientation = section .orientation
147+
148+ assert orientation is expected_orientation
112149
113150 def it_can_change_its_orientation (self , orientation_set_fixture ):
114- section , new_orientation , expected_xml = orientation_set_fixture
151+ sectPr , new_orientation , expected_xml = orientation_set_fixture
152+ section = Section (sectPr , None )
153+
115154 section .orientation = new_orientation
155+
116156 assert section ._sectPr .xml == expected_xml
117157
118158 def it_knows_its_page_margins (self , margins_get_fixture ):
119- section , margin_prop_name , expected_value = margins_get_fixture
159+ sectPr , margin_prop_name , expected_value = margins_get_fixture
160+ section = Section (sectPr , None )
161+
120162 value = getattr (section , margin_prop_name )
163+
121164 assert value == expected_value
122165
123166 def it_can_change_its_page_margins (self , margins_set_fixture ):
124- section , margin_prop_name , new_value , expected_xml = (
125- margins_set_fixture
126- )
167+ sectPr , margin_prop_name , new_value , expected_xml = margins_set_fixture
168+ section = Section ( sectPr , None )
169+
127170 setattr (section , margin_prop_name , new_value )
171+
128172 assert section ._sectPr .xml == expected_xml
129173
130174 # fixtures -------------------------------------------------------
@@ -142,8 +186,8 @@ def it_can_change_its_page_margins(self, margins_set_fixture):
142186 ])
143187 def margins_get_fixture (self , request ):
144188 sectPr_cxml , margin_prop_name , expected_value = request .param
145- section = Section ( element (sectPr_cxml ) )
146- return section , margin_prop_name , expected_value
189+ sectPr = element (sectPr_cxml )
190+ return sectPr , margin_prop_name , expected_value
147191
148192 @pytest .fixture (params = [
149193 ('w:sectPr' , 'left_margin' , Inches (1 ),
@@ -166,9 +210,9 @@ def margins_get_fixture(self, request):
166210 ])
167211 def margins_set_fixture (self , request ):
168212 sectPr_cxml , property_name , new_value , expected_cxml = request .param
169- section = Section ( element (sectPr_cxml ) )
213+ sectPr = element (sectPr_cxml )
170214 expected_xml = xml (expected_cxml )
171- return section , property_name , new_value , expected_xml
215+ return sectPr , property_name , new_value , expected_xml
172216
173217 @pytest .fixture (params = [
174218 ('w:sectPr/w:pgSz{w:orient=landscape}' , WD_ORIENT .LANDSCAPE ),
@@ -178,8 +222,8 @@ def margins_set_fixture(self, request):
178222 ])
179223 def orientation_get_fixture (self , request ):
180224 sectPr_cxml , expected_orientation = request .param
181- section = Section ( element (sectPr_cxml ) )
182- return section , expected_orientation
225+ sectPr = element (sectPr_cxml )
226+ return sectPr , expected_orientation
183227
184228 @pytest .fixture (params = [
185229 (WD_ORIENT .LANDSCAPE , 'w:sectPr/w:pgSz{w:orient=landscape}' ),
@@ -188,9 +232,9 @@ def orientation_get_fixture(self, request):
188232 ])
189233 def orientation_set_fixture (self , request ):
190234 new_orientation , expected_cxml = request .param
191- section = Section ( element ('w:sectPr' ) )
235+ sectPr = element ('w:sectPr' )
192236 expected_xml = xml (expected_cxml )
193- return section , new_orientation , expected_xml
237+ return sectPr , new_orientation , expected_xml
194238
195239 @pytest .fixture (params = [
196240 ('w:sectPr/w:pgSz{w:h=2880}' , Inches (2 )),
@@ -199,18 +243,18 @@ def orientation_set_fixture(self, request):
199243 ])
200244 def page_height_get_fixture (self , request ):
201245 sectPr_cxml , expected_page_height = request .param
202- section = Section ( element (sectPr_cxml ) )
203- return section , expected_page_height
246+ sectPr = element (sectPr_cxml )
247+ return sectPr , expected_page_height
204248
205249 @pytest .fixture (params = [
206250 (None , 'w:sectPr/w:pgSz' ),
207251 (Inches (2 ), 'w:sectPr/w:pgSz{w:h=2880}' ),
208252 ])
209253 def page_height_set_fixture (self , request ):
210254 new_page_height , expected_cxml = request .param
211- section = Section ( element ('w:sectPr' ) )
255+ sectPr = element ('w:sectPr' )
212256 expected_xml = xml (expected_cxml )
213- return section , new_page_height , expected_xml
257+ return sectPr , new_page_height , expected_xml
214258
215259 @pytest .fixture (params = [
216260 ('w:sectPr/w:pgSz{w:w=1440}' , Inches (1 )),
@@ -219,18 +263,18 @@ def page_height_set_fixture(self, request):
219263 ])
220264 def page_width_get_fixture (self , request ):
221265 sectPr_cxml , expected_page_width = request .param
222- section = Section ( element (sectPr_cxml ) )
223- return section , expected_page_width
266+ sectPr = element (sectPr_cxml )
267+ return sectPr , expected_page_width
224268
225269 @pytest .fixture (params = [
226270 (None , 'w:sectPr/w:pgSz' ),
227271 (Inches (4 ), 'w:sectPr/w:pgSz{w:w=5760}' ),
228272 ])
229273 def page_width_set_fixture (self , request ):
230274 new_page_width , expected_cxml = request .param
231- section = Section ( element ('w:sectPr' ) )
275+ sectPr = element ('w:sectPr' )
232276 expected_xml = xml (expected_cxml )
233- return section , new_page_width , expected_xml
277+ return sectPr , new_page_width , expected_xml
234278
235279 @pytest .fixture (params = [
236280 ('w:sectPr' , WD_SECTION .NEW_PAGE ),
@@ -243,8 +287,8 @@ def page_width_set_fixture(self, request):
243287 ])
244288 def start_type_get_fixture (self , request ):
245289 sectPr_cxml , expected_start_type = request .param
246- section = Section ( element (sectPr_cxml ) )
247- return section , expected_start_type
290+ sectPr = element (sectPr_cxml )
291+ return sectPr , expected_start_type
248292
249293 @pytest .fixture (params = [
250294 ('w:sectPr/w:type{w:val=oddPage}' , WD_SECTION .EVEN_PAGE ,
@@ -262,6 +306,6 @@ def start_type_get_fixture(self, request):
262306 ])
263307 def start_type_set_fixture (self , request ):
264308 initial_cxml , new_start_type , expected_cxml = request .param
265- section = Section ( element (initial_cxml ) )
309+ sectPr = element (initial_cxml )
266310 expected_xml = xml (expected_cxml )
267- return section , new_start_type , expected_xml
311+ return sectPr , new_start_type , expected_xml
0 commit comments