1010
1111from helpers import saved_docx_path , test_text
1212
13- test_style = 'Heading1'
13+
14+ TEST_STYLE = 'Heading1'
1415
1516
1617# when ====================================================
1718
1819@when ('I add a run to the paragraph' )
19- def step_when_add_new_run_to_paragraph (context ):
20+ def when_add_new_run_to_paragraph (context ):
2021 context .r = context .p .add_run ()
2122
2223
2324@when ('I add text to the run' )
24- def step_when_add_new_text_to_run (context ):
25+ def when_add_new_text_to_run (context ):
2526 context .r .add_text (test_text )
2627
2728
2829@when ('I set the paragraph style' )
29- def step_when_set_paragraph_style (context ):
30- context .p .add_run ().add_text (test_text )
31- context .p .style = test_style
30+ def when_I_set_the_paragraph_style (context ):
31+ context .paragraph .add_run ().add_text (test_text )
32+ context .paragraph .style = TEST_STYLE
3233
3334
3435# then =====================================================
3536
3637@then ('the document contains the text I added' )
37- def step_then_document_contains_text_I_added (context ):
38+ def then_document_contains_text_I_added (context ):
3839 document = Document (saved_docx_path )
3940 paragraphs = document .paragraphs
4041 p = paragraphs [- 1 ]
@@ -43,8 +44,6 @@ def step_then_document_contains_text_I_added(context):
4344
4445
4546@then ('the paragraph has the style I set' )
46- def step_then_paragraph_has_the_style_I_set (context ):
47- document = Document (saved_docx_path )
48- paragraphs = document .paragraphs
49- p = paragraphs [- 1 ]
50- assert p .style == test_style
47+ def then_the_paragraph_has_the_style_I_set (context ):
48+ paragraph = Document (saved_docx_path ).paragraphs [- 1 ]
49+ assert paragraph .style == TEST_STYLE
0 commit comments