|
27 | 27 | 'WD_STYLE_TYPE.TABLE': WD_STYLE_TYPE.TABLE, |
28 | 28 | } |
29 | 29 |
|
| 30 | +tri_state_vals = { |
| 31 | + 'True': True, |
| 32 | + 'False': False, |
| 33 | + 'None': None, |
| 34 | +} |
| 35 | + |
30 | 36 |
|
31 | 37 | # given =================================================== |
32 | 38 |
|
@@ -69,6 +75,17 @@ def given_a_style_having_a_known_attr_name(context, attr_name): |
69 | 75 | context.style = document.styles['Normal'] |
70 | 76 |
|
71 | 77 |
|
| 78 | +@given('a style having hidden set {setting}') |
| 79 | +def given_a_style_having_hidden_set_setting(context, setting): |
| 80 | + document = Document(test_docx('sty-behav-props')) |
| 81 | + style_name = { |
| 82 | + 'on': 'Foo', |
| 83 | + 'off': 'Bar', |
| 84 | + 'no setting': 'Baz', |
| 85 | + }[setting] |
| 86 | + context.style = document.styles[style_name] |
| 87 | + |
| 88 | + |
72 | 89 | @given('a style of type {style_type}') |
73 | 90 | def given_a_style_of_type(context, style_type): |
74 | 91 | document = Document(test_docx('sty-known-styles')) |
@@ -103,6 +120,12 @@ def when_I_assign_value_to_style_base_style(context, value_key): |
103 | 120 | context.style.base_style = value |
104 | 121 |
|
105 | 122 |
|
| 123 | +@when('I assign {value} to style.hidden') |
| 124 | +def when_I_assign_value_to_style_hidden(context, value): |
| 125 | + style, new_value = context.style, tri_state_vals[value] |
| 126 | + style.hidden = new_value |
| 127 | + |
| 128 | + |
106 | 129 | @when('I call add_style(\'{name}\', {type_str}, builtin={builtin_str})') |
107 | 130 | def when_I_call_add_style(context, name, type_str, builtin_str): |
108 | 131 | styles = context.document.styles |
@@ -177,6 +200,12 @@ def then_style_font_is_the_Font_object_for_the_style(context): |
177 | 200 | assert font.element is style.element |
178 | 201 |
|
179 | 202 |
|
| 203 | +@then('style.hidden is {value}') |
| 204 | +def then_style_hidden_is_value(context, value): |
| 205 | + style, expected_value = context.style, tri_state_vals[value] |
| 206 | + assert style.hidden is expected_value |
| 207 | + |
| 208 | + |
180 | 209 | @then('style.name is the {which} name') |
181 | 210 | def then_style_name_is_the_which_name(context, which): |
182 | 211 | expected_name = { |
|
0 commit comments