10
10
11
11
from docx import Document
12
12
13
+ from helpers import test_docx
14
+
13
15
14
16
# given ===================================================
15
17
16
18
@given ('a table cell' )
17
19
def given_a_table_cell (context ):
18
- table = Document (). add_table ( rows = 2 , cols = 2 )
20
+ table = Document (test_docx ( 'tbl-2x2-table' )). tables [ 0 ]
19
21
context .cell = table .cell (0 , 0 )
20
22
21
23
22
24
# when =====================================================
23
25
26
+ @when ('I add a 2 x 2 table into the first cell' )
27
+ def when_I_add_a_2x2_table_into_the_first_cell (context ):
28
+ context .table_ = context .cell .add_table (2 , 2 )
29
+
30
+
24
31
@when ('I assign a string to the cell text attribute' )
25
32
def when_assign_string_to_cell_text_attribute (context ):
26
33
cell = context .cell
@@ -31,6 +38,14 @@ def when_assign_string_to_cell_text_attribute(context):
31
38
32
39
# then =====================================================
33
40
41
+ @then ('cell.tables[0] is a 2 x 2 table' )
42
+ def then_cell_tables_0_is_a_2x2_table (context ):
43
+ cell = context .cell
44
+ table = cell .tables [0 ]
45
+ assert len (table .rows ) == 2
46
+ assert len (table .columns ) == 2
47
+
48
+
34
49
@then ('the cell contains the string I assigned' )
35
50
def then_cell_contains_string_assigned (context ):
36
51
cell , expected_text = context .cell , context .expected_text
0 commit comments