def given_a_Settings_object_with_or_without_odd_and_even_hdrs( context, with_or_without): testfile_name = { "with": "doc-odd-even-hdrs", "without": "sct-section-props" }[with_or_without] context.settings = Document(test_docx(testfile_name)).settings
def given_a_section_having_known_orientation(context, orientation): section_idx = { 'landscape': 0, 'portrait': 1 }[orientation] document = Document(test_docx('sct-section-props')) context.section = document.sections[section_idx]
def given_a_style_having_priority_of_setting(context, setting): document = Document(test_docx('sty-behav-props')) style_name = { 'no setting': 'Baz', '42': 'Foo', }[setting] context.style = document.styles[style_name]
def given_a_header_having_or_no_definition(context, having_or_no): filename = { 'having a': 'hdr-header-props', 'having no': 'doc-default', }[having_or_no] document = Document(test_docx(filename)) context.header = document.sections[0].header
def given_a_font_having_typeface_name(context, name): document = Document(test_docx('txt-font-props')) style_name = { 'not specified': 'Normal', 'Avenir Black': 'Having Typeface', }[name] context.font = document.styles[style_name].font
def given_a_font_of_size(context, size): document = Document(test_docx('txt-font-props')) style_name = { 'unspecified': 'Normal', '14 pt': 'Having Typeface', '18 pt': 'Large Size', }[size] context.font = document.styles[style_name].font
def given_a_font_having_vertAlign_state(context, vertAlign_state): style_name = { 'inherited': 'Normal', 'subscript': 'Subscript', 'superscript': 'Superscript', }[vertAlign_state] document = Document(test_docx('txt-font-props')) context.font = document.styles[style_name].font
def given_a_font_having_color_highlighting(context, color): paragraph_index = { 'no': 0, 'yellow': 1, 'bright green': 2, }[color] document = Document(test_docx('txt-font-highlight-color')) context.font = document.paragraphs[paragraph_index].runs[0].font
def given_a_table_having_a_width_of_width_desc(context, width_desc): col_idx = { 'no explicit setting': 0, '1440': 1, }[width_desc] docx_path = test_docx('tbl-col-props') document = Document(docx_path) context.column = document.tables[0].columns[col_idx]
def given_a_table_having_an_autofit_layout_of_autofit(context, autofit): tbl_idx = { 'no explicit setting': 0, 'autofit': 1, 'fixed': 2, }[autofit] document = Document(test_docx('tbl-props')) context.table_ = document.tables[tbl_idx]
def given_a_style_having_unhide_when_used_setting(context, setting): document = Document(test_docx('sty-behav-props')) style_name = { 'on': 'Foo', 'off': 'Bar', 'no setting': 'Baz', }[setting] context.style = document.styles[style_name]
def given_a_run_having_style(context, style): run_idx = { 'no explicit': 0, 'Emphasis': 1, 'Strong': 2, }[style] context.document = document = Document(test_docx('run-char-style')) context.run = document.paragraphs[0].runs[run_idx]
def given_a_latent_style_having_priority_of_setting(context, setting): latent_style_name = { '42': 'Normal', 'no setting': 'Subtitle', }[setting] document = Document(test_docx('sty-known-styles')) latent_styles = document.styles.latent_styles context.latent_style = latent_styles[latent_style_name]
def given_a_paragraph_format_having_align_type_alignment(context, type): style_name = { 'inherited': 'Normal', 'center': 'Base', 'right': 'Citation', }[type] document = Document(test_docx('sty-known-styles')) context.paragraph_format = document.styles[style_name].paragraph_format
def given_a_paragraph_format_having_setting_line_spacing(context, setting): style_name = { 'inherited': 'Normal', '14 pt': 'Base', 'double': 'Citation', }[setting] document = Document(test_docx('sty-known-styles')) context.paragraph_format = document.styles[style_name].paragraph_format
def given_a_paragraph_format_having_prop_set(context, prop_name, setting): style_name = { 'to inherit': 'Normal', 'On': 'Base', 'Off': 'Citation', }[setting] document = Document(test_docx('sty-known-styles')) context.paragraph_format = document.styles[style_name].paragraph_format
def given_a_table_having_table_direction_setting(context, setting): table_idx = [ 'to inherit', 'right-to-left', 'left-to-right' ].index(setting) document = Document(test_docx('tbl-on-off-props')) context.table_ = document.tables[table_idx]
def given_a_latent_style_having_prop_setting(context, prop_name, setting): latent_style_name = { 'on': 'Normal', 'off': 'Title', 'no setting': 'Subtitle', }[setting] document = Document(test_docx('sty-known-styles')) latent_styles = document.styles.latent_styles context.latent_style = latent_styles[latent_style_name]
def given_a_run_having_underline_type(context, underline_type): run_idx = { 'inherited': 0, 'no': 1, 'single': 2, 'double': 3 }[underline_type] document = Document(test_docx('run-enumerated-props')) context.run = document.paragraphs[0].runs[run_idx]
def given_a_style_based_on_setting(context, base_style): style_name = { 'no style': 'Base', 'Normal': 'Sub Normal', 'Base': 'Citation', }[base_style] document = Document(test_docx('sty-known-styles')) context.styles = document.styles context.style = document.styles[style_name]
def given_a_style_of_type(context, style_type): document = Document(test_docx('sty-known-styles')) name = { 'WD_STYLE_TYPE.CHARACTER': 'Default Paragraph Font', 'WD_STYLE_TYPE.LIST': 'No List', 'WD_STYLE_TYPE.PARAGRAPH': 'Normal', 'WD_STYLE_TYPE.TABLE': 'Normal Table', }[style_type] context.style = document.styles[name]
def given_a_table_having_style(context, style): table_idx = { "no explicit": 0, "Table Grid": 1, "Light Shading - Accent 1": 2 }[style] document = Document(test_docx("tbl-having-applied-style")) context.document = document context.table_ = document.tables[table_idx]
def given_a_font_having_type_underline(context, underline_type): style_name = { 'inherited': 'Normal', 'no': 'None Underlined', 'single': 'Underlined', 'double': 'Double Underlined', }[underline_type] document = Document(test_docx('txt-font-props')) context.font = document.styles[style_name].font
def given_a_table_row_having_height_of_state(context, state): table_idx = { 'no explicit setting': 0, '2 inches': 2, '3 inches': 3 }[state] document = Document(test_docx('tbl-props')) table = document.tables[table_idx] context.row = table.rows[0]
def given_a_paragraph_having_style(context, style_state): paragraph_idx = { 'no specified': 0, 'a missing': 1, 'Heading 1': 2, 'Body Text': 3, }[style_state] document = context.document = Document(test_docx('par-known-styles')) context.paragraph = document.paragraphs[paragraph_idx]
def given_a_3x3_table_having_span_state(context, span_state): table_idx = { "only uniform cells": 0, "a horizontal span": 1, "a vertical span": 2, "a combined span": 3, }[span_state] document = Document(test_docx("tbl-cell-access")) context.table_ = document.tables[table_idx]
def given_a_3x3_table_having_span_state(context, span_state): table_idx = { 'only uniform cells': 0, 'a horizontal span': 1, 'a vertical span': 2, 'a combined span': 3, }[span_state] document = Document(test_docx('tbl-cell-access')) context.table_ = document.tables[table_idx]
def given_a_table_having_style(context, style): table_idx = { 'no explicit': 0, 'Table Grid': 1, 'Light Shading - Accent 1': 2, }[style] document = Document(test_docx('tbl-having-applied-style')) context.document = document context.table_ = document.tables[table_idx]
def given_a_paragraph_format_having_type_indent_value(context, type, value): style_name = { 'inherit': 'Normal', '18 pt': 'Base', '17.3 pt': 'Base', '-17.3 pt': 'Citation', '46.1 pt': 'Citation', }[value] document = Document(test_docx('sty-known-styles')) context.paragraph_format = document.styles[style_name].paragraph_format
def given_a_table_having_alignment_alignment(context, alignment): table_idx = { 'inherited': 3, 'left': 4, 'right': 5, 'center': 6, }[alignment] docx_path = test_docx('tbl-props') document = Document(docx_path) context.table_ = document.tables[table_idx]
def given_a_table_row_having_height_rule_state(context, state): table_idx = { 'no explicit setting': 0, 'automatic': 1, 'at least': 2, 'exactly': 3 }[state] document = Document(test_docx('tbl-props')) table = document.tables[table_idx] context.row = table.rows[0]
def given_a_Cell_object_with_vertical_alignment_as_cell(context, state): table_idx = { 'inherited': 0, 'bottom': 1, 'center': 2, 'top': 3, }[state] document = Document(test_docx('tbl-props')) table = document.tables[table_idx] context.cell = table.cell(0, 0)
def given_a_style_having_next_paragraph_style_setting(context, setting): document = Document(test_docx('sty-known-styles')) style_name = { 'Sub Normal': 'Citation', 'Foobar': 'Sub Normal', 'Base': 'Foo', 'no setting': 'Base', }[setting] context.styles = document.styles context.style = document.styles[style_name]
def given_a_paragraph_align_type_alignment(context, align_type): paragraph_idx = { 'inherited': 0, 'left': 1, 'center': 2, 'right': 3, 'justified': 4, }[align_type] document = Document(test_docx('par-alignment')) context.paragraph = document.paragraphs[paragraph_idx]
def given_a_section_having_start_type(context, start_type): section_idx = { 'CONTINUOUS': 0, 'NEW_PAGE': 1, 'ODD_PAGE': 2, 'EVEN_PAGE': 3, 'NEW_COLUMN': 4, }[start_type] document = Document(test_docx('sct-section-props')) context.section = document.sections[section_idx]