@@ -55,11 +55,9 @@ def it_should_raise_if_not_a_Word_file(self, Package_, package_, docx_):
55
55
Document ._open (docx_ )
56
56
57
57
def it_can_add_a_heading (self , add_heading_fixture ):
58
- document , add_paragraph_ , paragraph_ , text , level , style = (
59
- add_heading_fixture
60
- )
58
+ document , text , level , style , paragraph_ = add_heading_fixture
61
59
paragraph = document .add_heading (text , level )
62
- add_paragraph_ .assert_called_once_with (text , style )
60
+ document . add_paragraph .assert_called_once_with (text , style )
63
61
assert paragraph is paragraph_
64
62
65
63
def it_should_raise_on_heading_level_out_of_range (self , document ):
@@ -69,11 +67,11 @@ def it_should_raise_on_heading_level_out_of_range(self, document):
69
67
document .add_heading (level = 10 )
70
68
71
69
def it_can_add_a_paragraph (self , add_paragraph_fixture ):
72
- document , document_part_ , text , style , paragraph_ = (
73
- add_paragraph_fixture
74
- )
70
+ document , text , style , paragraph_ = add_paragraph_fixture
75
71
paragraph = document .add_paragraph (text , style )
76
- document_part_ .add_paragraph .assert_called_once_with (text , style )
72
+ document ._document_part .add_paragraph .assert_called_once_with (
73
+ text , style
74
+ )
77
75
assert paragraph is paragraph_
78
76
79
77
def it_can_add_a_page_break (self , add_page_break_fixture ):
@@ -101,12 +99,10 @@ def it_can_add_a_section(self, add_section_fixture):
101
99
assert section is section_
102
100
103
101
def it_can_add_a_table (self , add_table_fixture ):
104
- document , rows , cols , style , document_part_ , expected_style , table_ = (
105
- add_table_fixture
106
- )
102
+ document , rows , cols , style , table_ = add_table_fixture
107
103
table = document .add_table (rows , cols , style )
108
- document_part_ .add_table .assert_called_once_with (rows , cols )
109
- assert table .style == expected_style
104
+ document . _document_part .add_table .assert_called_once_with (rows , cols )
105
+ assert table .style == style
110
106
assert table == table_
111
107
112
108
def it_provides_access_to_the_document_inline_shapes (self , document ):
@@ -165,21 +161,25 @@ def it_creates_numbering_part_on_first_access_if_not_present(
165
161
166
162
@pytest .fixture (params = [
167
163
('' , None ),
168
- ('' , 'Heading1 ' ),
169
- ('foo\r bar' , 'BodyText ' ),
164
+ ('' , 'Heading 1 ' ),
165
+ ('foo\r bar' , 'Body Text ' ),
170
166
])
171
- def add_paragraph_fixture (
172
- self , request , document , document_part_ , paragraph_ ):
167
+ def add_paragraph_fixture (self , request , document , document_part_ ,
168
+ paragraph_ ):
173
169
text , style = request .param
174
- return document , document_part_ , text , style , paragraph_
170
+ return document , text , style , paragraph_
175
171
176
- @pytest .fixture (params = [0 , 1 , 2 , 5 , 9 ])
177
- def add_heading_fixture (
178
- self , request , document , add_paragraph_ , paragraph_ ):
179
- level = request .param
172
+ @pytest .fixture (params = [
173
+ (0 , 'Title' ),
174
+ (1 , 'Heading 1' ),
175
+ (2 , 'Heading 2' ),
176
+ (9 , 'Heading 9' ),
177
+ ])
178
+ def add_heading_fixture (self , request , document , add_paragraph_ ,
179
+ paragraph_ ):
180
+ level , style = request .param
180
181
text = 'Spam vs. Bacon'
181
- style = 'Title' if level == 0 else 'Heading%d' % level
182
- return document , add_paragraph_ , paragraph_ , text , level , style
182
+ return document , text , level , style , paragraph_
183
183
184
184
@pytest .fixture
185
185
def add_page_break_fixture (
@@ -199,14 +199,11 @@ def add_picture_fixture(self, request, run_, picture_):
199
199
def add_section_fixture (self , document , start_type_ , section_ ):
200
200
return document , start_type_ , section_
201
201
202
- @pytest .fixture ( params = [ None , 'LightShading-Accent1' , 'foobar' ])
202
+ @pytest .fixture
203
203
def add_table_fixture (self , request , document , document_part_ , table_ ):
204
204
rows , cols = 4 , 2
205
- style = expected_style = request .param
206
- return (
207
- document , rows , cols , style , document_part_ , expected_style ,
208
- table_
209
- )
205
+ style = 'Light Shading Accent 1'
206
+ return document , rows , cols , style , table_
210
207
211
208
@pytest .fixture
212
209
def core_props_fixture (self , document , core_properties_ ):
0 commit comments