Skip to content

Commit 74931e2

Browse files
author
Steve Canny
committed
acpt: rewrite scenario for Document.add_table()
Add steps to check column and cell width are properly applied to a new table.
1 parent 280d46a commit 74931e2

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

features/doc-add-table.feature

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ Feature: Add a table
44
I need a way to add a table
55

66

7+
@wip
78
Scenario: Add a table specifying only row and column count
89
Given a blank document
910
When I add a 2 x 2 table specifying only row and column count
1011
Then the document contains a 2 x 2 table
1112
And table.style is styles['Normal Table']
13+
And the width of each column is 3.0 inches
14+
And the width of each cell is 3.0 inches
1215

1316

1417
Scenario: Add a table specifying style

features/steps/table.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,3 +358,19 @@ def _cell(table, idx):
358358
idx, inches = int(n_str) - 1, float(inches_str)
359359
cell = _cell(context.table_, idx)
360360
assert cell.width == Inches(inches), 'got %s' % cell.width.inches
361+
362+
363+
@then('the width of each cell is {inches} inches')
364+
def then_the_width_of_each_cell_is_inches(context, inches):
365+
table = context.table_
366+
expected_width = Inches(float(inches))
367+
for cell in table._cells:
368+
assert cell.width == expected_width, 'got %s' % cell.width.inches
369+
370+
371+
@then('the width of each column is {inches} inches')
372+
def then_the_width_of_each_column_is_inches(context, inches):
373+
table = context.table_
374+
expected_width = Inches(float(inches))
375+
for column in table.columns:
376+
assert column.width == expected_width, 'got %s' % column.width.inches

0 commit comments

Comments
 (0)