File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -56,6 +56,17 @@ def given_a_table(context):
5656 context .table_ = Document ().add_table (rows = 2 , cols = 2 )
5757
5858
59+ @given ('a table column having a width of {width_desc}' )
60+ def given_a_table_having_a_width_of_width_desc (context , width_desc ):
61+ col_idx = {
62+ 'no explicit setting' : 0 ,
63+ '1440' : 1 ,
64+ }[width_desc ]
65+ docx_path = test_docx ('tbl-col-props' )
66+ document = Document (docx_path )
67+ context .column = document .tables [0 ].columns [col_idx ]
68+
69+
5970@given ('a table having an applied style' )
6071def given_a_table_having_an_applied_style (context ):
6172 docx_path = test_docx ('tbl-having-applied-style' )
@@ -267,6 +278,15 @@ def then_new_row_has_2_cells(context):
267278 assert len (context .row .cells ) == 2
268279
269280
281+ @then ('the reported column width is {width_emu}' )
282+ def then_the_reported_column_width_is_width_emu (context , width_emu ):
283+ expected_value = {
284+ 'None' : None ,
285+ '914400' : 914400 ,
286+ }[width_emu ]
287+ assert context .column .width == expected_value
288+
289+
270290@then ('the table style matches the name I applied' )
271291def then_table_style_matches_name_applied (context ):
272292 table = context .table_
Original file line number Diff line number Diff line change 1+ Feature : Get and set table column widths
2+ In order to produce properly formatted tables
3+ As an python-docx developer
4+ I need a way to get and set the width of a table's columns
5+
6+ @wip
7+ Scenario Outline : Get existing column width
8+ Given a table column having a width of <width>
9+ Then the reported column width is <width-emu>
10+
11+ Examples : table column width values
12+ | width | width -emu |
13+ | no explicit setting | None |
14+ | 1440 | 914400 |
You can’t perform that action at this time.
0 commit comments