File tree 7 files changed +24
-21
lines changed
7 files changed +24
-21
lines changed Original file line number Diff line number Diff line change @@ -5,14 +5,14 @@ Feature: Add a heading paragraph
5
5
6
6
7
7
Scenario : Add a heading specifying only its text
8
- Given a blank document
8
+ Given a document having built-in styles
9
9
When I add a heading specifying only its text
10
10
Then the style of the last paragraph is 'Heading 1'
11
11
And the last paragraph contains the heading text
12
12
13
13
14
14
Scenario Outline : Add a heading specifying level
15
- Given a blank document
15
+ Given a document having built-in styles
16
16
When I add a heading specifying level=<level>
17
17
Then the style of the last paragraph is '<style>'
18
18
Original file line number Diff line number Diff line change @@ -5,14 +5,14 @@ Feature: Add a table
5
5
6
6
7
7
Scenario : Add a table specifying only row and column count
8
- Given a blank document
8
+ Given a document having built-in styles
9
9
When I add a 2 x 2 table specifying only row and column count
10
10
Then the document contains a 2 x 2 table
11
11
And table.style is styles['Light Shading Accent 1' ]
12
12
13
13
14
14
Scenario : Add a table specifying style
15
- Given a blank document
15
+ Given a document having built-in styles
16
16
When I add a 2 x 2 table specifying style 'Table Grid'
17
17
Then the document contains a 2 x 2 table
18
18
And table.style is styles['Table Grid' ]
Original file line number Diff line number Diff line change 16
16
17
17
@given ('a document containing a table' )
18
18
def given_a_document_containing_a_table (context ):
19
- docx_path = test_docx ('blk-containing-table' )
20
- context .document = Document (docx_path )
19
+ context .document = Document (test_docx ('blk-containing-table' ))
21
20
22
21
23
22
@given ('a paragraph' )
Original file line number Diff line number Diff line change 24
24
25
25
@given ('a blank document' )
26
26
def given_a_blank_document (context ):
27
+ context .document = Document (test_docx ('doc-word-default-blank' ))
28
+
29
+
30
+ @given ('a document having built-in styles' )
31
+ def given_a_document_having_builtin_styles (context ):
27
32
context .document = Document ()
28
33
29
34
@@ -198,9 +203,8 @@ def then_document_tables_is_a_list_containing_three_tables(context):
198
203
199
204
200
205
@then ('the document contains a 2 x 2 table' )
201
- def then_document_contains_2x2_table (context ):
202
- document = context .document
203
- table = document .tables [- 1 ]
206
+ def then_the_document_contains_a_2x2_table (context ):
207
+ table = context .document .tables [- 1 ]
204
208
assert isinstance (table , Table )
205
209
assert len (table .rows ) == 2
206
210
assert len (table .columns ) == 2
Original file line number Diff line number Diff line change @@ -16,8 +16,19 @@ def absjoin(*paths):
16
16
# scratch output docx file -------------
17
17
saved_docx_path = absjoin (scratch_dir , 'test_out.docx' )
18
18
19
+ bool_vals = {
20
+ 'True' : True ,
21
+ 'False' : False
22
+ }
23
+
19
24
test_text = 'python-docx was here!'
20
25
26
+ tri_state_vals = {
27
+ 'True' : True ,
28
+ 'False' : False ,
29
+ 'None' : None ,
30
+ }
31
+
21
32
22
33
def test_docx (name ):
23
34
"""
Original file line number Diff line number Diff line change 13
13
from docx .text .font import Font
14
14
from docx .text .parfmt import ParagraphFormat
15
15
16
- from helpers import test_docx
17
-
18
- bool_vals = {
19
- 'True' : True ,
20
- 'False' : False
21
- }
16
+ from helpers import bool_vals , test_docx , tri_state_vals
22
17
23
18
style_types = {
24
19
'WD_STYLE_TYPE.CHARACTER' : WD_STYLE_TYPE .CHARACTER ,
27
22
'WD_STYLE_TYPE.TABLE' : WD_STYLE_TYPE .TABLE ,
28
23
}
29
24
30
- tri_state_vals = {
31
- 'True' : True ,
32
- 'False' : False ,
33
- 'None' : None ,
34
- }
35
-
36
25
37
26
# given ===================================================
38
27
You can’t perform that action at this time.
0 commit comments