@@ -30,6 +30,14 @@ def given_a_run_having_bool_prop_set_on(context, bool_prop_name):
3030 context .run = run
3131
3232
33+ @given ('a run having known text and formatting' )
34+ def given_a_run_having_known_text_and_formatting (context ):
35+ run = Document ().add_paragraph ().add_run ('foobar' )
36+ run .bold = True
37+ run .italic = True
38+ context .run = run
39+
40+
3341@given ('a run having {underline_type} underline' )
3442def given_a_run_having_underline_type (context , underline_type ):
3543 run_idx = {
@@ -85,6 +93,11 @@ def when_assign_true_to_bool_run_prop(context, value_str, bool_prop_name):
8593 setattr (run , bool_prop_name , value )
8694
8795
96+ @when ('I clear the run' )
97+ def when_I_clear_the_run (context ):
98+ context .run .clear ()
99+
100+
88101@when ('I set the character style of the run to {char_style}' )
89102def when_I_set_the_character_style_of_the_run (context , char_style ):
90103 style_value = {
@@ -151,11 +164,22 @@ def then_run_appears_without_bool_prop(context, boolean_prop_name):
151164 assert getattr (run , boolean_prop_name ) is False
152165
153166
167+ @then ('the run contains no text' )
168+ def then_the_run_contains_no_text (context ):
169+ assert context .run .text == ''
170+
171+
154172@then ('the run contains the text I specified' )
155173def then_the_run_contains_the_text_I_specified (context ):
156174 assert context .run .text == test_text
157175
158176
177+ @then ('the run formatting is preserved' )
178+ def then_the_run_formatting_is_preserved (context ):
179+ assert context .run .bold is True
180+ assert context .run .italic is True
181+
182+
159183@then ('the run underline property value is {underline_value}' )
160184def then_the_run_underline_property_value_is (context , underline_value ):
161185 expected_value = {
0 commit comments