@@ -52,10 +52,12 @@ def it_should_raise_if_not_a_Word_file(self, Package_, package_, docx_):
52
52
Document ._open (docx_ )
53
53
54
54
def it_can_add_a_heading (self , add_heading_fixture ):
55
- document , add_paragraph_ , p_ , text , level , style = add_heading_fixture
56
- p = document .add_heading (text , level )
55
+ document , add_paragraph_ , paragraph_ , text , level , style = (
56
+ add_heading_fixture
57
+ )
58
+ paragraph = document .add_heading (text , level )
57
59
add_paragraph_ .assert_called_once_with (text , style )
58
- assert p is p_
60
+ assert paragraph is paragraph_
59
61
60
62
def it_should_raise_on_heading_level_out_of_range (self , document ):
61
63
with pytest .raises (ValueError ):
@@ -64,28 +66,28 @@ def it_should_raise_on_heading_level_out_of_range(self, document):
64
66
document .add_heading (level = 10 )
65
67
66
68
def it_can_add_an_empty_paragraph (self , add_empty_paragraph_fixture ):
67
- document , document_part_ , p_ = add_empty_paragraph_fixture
68
- p = document .add_paragraph ()
69
+ document , document_part_ , paragraph_ = add_empty_paragraph_fixture
70
+ paragraph = document .add_paragraph ()
69
71
document_part_ .add_paragraph .assert_called_once_with ()
70
- assert p is p_
72
+ assert paragraph is paragraph_
71
73
72
74
def it_can_add_a_paragraph_of_text (self , add_text_paragraph_fixture ):
73
- document , text , p_ = add_text_paragraph_fixture
74
- p = document .add_paragraph (text )
75
- p .add_run .assert_called_once_with (text )
75
+ document , text = add_text_paragraph_fixture
76
+ paragraph = document .add_paragraph (text )
77
+ paragraph .add_run .assert_called_once_with (text )
76
78
77
79
def it_can_add_a_styled_paragraph (self , add_styled_paragraph_fixture ):
78
- document , style , p_ = add_styled_paragraph_fixture
79
- p = document .add_paragraph (style = style )
80
- assert p .style == style
80
+ document , style = add_styled_paragraph_fixture
81
+ paragraph = document .add_paragraph (style = style )
82
+ assert paragraph .style == style
81
83
82
84
def it_can_add_a_page_break (self , add_page_break_fixture ):
83
- document , document_part_ , p_ , r_ = add_page_break_fixture
84
- p = document .add_page_break ()
85
+ document , document_part_ , paragraph_ , run_ = add_page_break_fixture
86
+ paragraph = document .add_page_break ()
85
87
document_part_ .add_paragraph .assert_called_once_with ()
86
- p_ .add_run .assert_called_once_with ()
87
- r_ .add_break .assert_called_once_with (WD_BREAK .PAGE )
88
- assert p is p_
88
+ paragraph_ .add_run .assert_called_once_with ()
89
+ run_ .add_break .assert_called_once_with (WD_BREAK .PAGE )
90
+ assert paragraph is paragraph_
89
91
90
92
def it_can_add_a_picture (self , add_picture_fixture ):
91
93
(document , image_path , width , height , inline_shapes_ , expected_width ,
@@ -176,19 +178,22 @@ def it_creates_styles_part_on_first_access_if_not_present(
176
178
# fixtures -------------------------------------------------------
177
179
178
180
@pytest .fixture
179
- def add_empty_paragraph_fixture (self , document , document_part_ , p_ ):
180
- return document , document_part_ , p_
181
+ def add_empty_paragraph_fixture (
182
+ self , document , document_part_ , paragraph_ ):
183
+ return document , document_part_ , paragraph_
181
184
182
185
@pytest .fixture (params = [0 , 1 , 2 , 5 , 9 ])
183
- def add_heading_fixture (self , request , document , add_paragraph_ , p_ ):
186
+ def add_heading_fixture (
187
+ self , request , document , add_paragraph_ , paragraph_ ):
184
188
level = request .param
185
189
text = 'Spam vs. Bacon'
186
190
style = 'Title' if level == 0 else 'Heading%d' % level
187
- return document , add_paragraph_ , p_ , text , level , style
191
+ return document , add_paragraph_ , paragraph_ , text , level , style
188
192
189
193
@pytest .fixture
190
- def add_page_break_fixture (self , document , document_part_ , p_ , r_ ):
191
- return document , document_part_ , p_ , r_
194
+ def add_page_break_fixture (
195
+ self , document , document_part_ , paragraph_ , run_ ):
196
+ return document , document_part_ , paragraph_ , run_
192
197
193
198
@pytest .fixture (params = [
194
199
(None , None , 200 , 100 ),
@@ -213,9 +218,9 @@ def add_section_fixture(self, document, start_type_, section_):
213
218
return document , start_type_ , section_
214
219
215
220
@pytest .fixture
216
- def add_styled_paragraph_fixture (self , document , p_ ):
221
+ def add_styled_paragraph_fixture (self , document ):
217
222
style = 'foobaresque'
218
- return document , style , p_
223
+ return document , style
219
224
220
225
@pytest .fixture (params = [None , 'LightShading-Accent1' , 'foobar' ])
221
226
def add_table_fixture (self , request , document , document_part_ , table_ ):
@@ -227,9 +232,9 @@ def add_table_fixture(self, request, document, document_part_, table_):
227
232
)
228
233
229
234
@pytest .fixture
230
- def add_text_paragraph_fixture (self , document , p_ ):
235
+ def add_text_paragraph_fixture (self , document ):
231
236
text = 'foobar\r barfoo'
232
- return document , text , p_
237
+ return document , text
233
238
234
239
@pytest .fixture
235
240
def init_fixture (self , docx_ , open_ ):
@@ -261,9 +266,9 @@ def tables_fixture(self, document, tables_):
261
266
# fixture components ---------------------------------------------
262
267
263
268
@pytest .fixture
264
- def add_paragraph_ (self , request , p_ ):
269
+ def add_paragraph_ (self , request , paragraph_ ):
265
270
return method_mock (
266
- request , Document , 'add_paragraph' , return_value = p_
271
+ request , Document , 'add_paragraph' , return_value = paragraph_
267
272
)
268
273
269
274
@pytest .fixture
@@ -282,11 +287,12 @@ def document(self, open_):
282
287
283
288
@pytest .fixture
284
289
def document_part_ (
285
- self , request , p_ , paragraphs_ , section_ , table_ , tables_ ):
290
+ self , request , paragraph_ , paragraphs_ , section_ , table_ ,
291
+ tables_ ):
286
292
document_part_ = instance_mock (
287
293
request , DocumentPart , content_type = CT .WML_DOCUMENT_MAIN
288
294
)
289
- document_part_ .add_paragraph .return_value = p_
295
+ document_part_ .add_paragraph .return_value = paragraph_
290
296
document_part_ .add_section .return_value = section_
291
297
document_part_ .add_table .return_value = table_
292
298
document_part_ .paragraphs = paragraphs_
@@ -325,10 +331,10 @@ def open_(self, request, document_part_, package_):
325
331
)
326
332
327
333
@pytest .fixture
328
- def p_ (self , request , r_ ):
329
- p_ = instance_mock (request , Paragraph )
330
- p_ .add_run .return_value = r_
331
- return p_
334
+ def paragraph_ (self , request , run_ ):
335
+ paragraph_ = instance_mock (request , Paragraph )
336
+ paragraph_ .add_run .return_value = run_
337
+ return paragraph_
332
338
333
339
@pytest .fixture
334
340
def Package_ (self , request , package_ ):
@@ -347,7 +353,7 @@ def paragraphs_(self, request):
347
353
return instance_mock (request , list )
348
354
349
355
@pytest .fixture
350
- def r_ (self , request ):
356
+ def run_ (self , request ):
351
357
return instance_mock (request , Run )
352
358
353
359
@pytest .fixture
0 commit comments