2626
2727class DescribeTable (object ):
2828
29+ def it_can_add_a_row (self , add_row_fixture ):
30+ table , expected_xml = add_row_fixture
31+ row = table .add_row ()
32+ assert table ._tbl .xml == expected_xml
33+ assert isinstance (row , _Row )
34+ assert row ._tr is table ._tbl .tr_lst [- 1 ]
35+ assert row ._parent is table
36+
37+ def it_can_add_a_column (self , add_column_fixture ):
38+ table , width , expected_xml = add_column_fixture
39+ column = table .add_column (width )
40+ assert table ._tbl .xml == expected_xml
41+ assert isinstance (column , _Column )
42+ assert column ._gridCol is table ._tbl .tblGrid .gridCol_lst [- 1 ]
43+ assert column ._parent is table
44+
45+ def it_provides_access_to_a_cell_by_row_and_col_indices (self , table ):
46+ for row_idx in range (2 ):
47+ for col_idx in range (2 ):
48+ cell = table .cell (row_idx , col_idx )
49+ assert isinstance (cell , _Cell )
50+ tr = table ._tbl .tr_lst [row_idx ]
51+ tc = tr .tc_lst [col_idx ]
52+ assert tc is cell ._tc
53+
54+ def it_provides_access_to_the_table_rows (self , table ):
55+ rows = table .rows
56+ assert isinstance (rows , _Rows )
57+
58+ def it_provides_access_to_the_table_columns (self , table ):
59+ columns = table .columns
60+ assert isinstance (columns , _Columns )
61+
62+ def it_provides_access_to_the_cells_in_a_column (self , col_cells_fixture ):
63+ table , column_idx , expected_cells = col_cells_fixture
64+ column_cells = table .column_cells (column_idx )
65+ assert column_cells == expected_cells
66+
67+ def it_provides_access_to_the_cells_in_a_row (self , row_cells_fixture ):
68+ table , row_idx , expected_cells = row_cells_fixture
69+ row_cells = table .row_cells (row_idx )
70+ assert row_cells == expected_cells
71+
2972 def it_knows_its_alignment_setting (self , alignment_get_fixture ):
3073 table , expected_value = alignment_get_fixture
3174 assert table .alignment == expected_value
@@ -44,6 +87,10 @@ def it_can_change_its_autofit_setting(self, autofit_set_fixture):
4487 table .autofit = new_value
4588 assert table ._tbl .xml == expected_xml
4689
90+ def it_knows_it_is_the_table_its_children_belong_to (self , table_fixture ):
91+ table = table_fixture
92+ assert table .table is table
93+
4794 def it_knows_its_table_style (self , style_get_fixture ):
4895 table , style_id_ , style_ = style_get_fixture
4996 style = table .style
@@ -60,58 +107,6 @@ def it_can_change_its_table_style(self, style_set_fixture):
60107 )
61108 assert table ._tbl .xml == expected_xml
62109
63- def it_knows_it_is_the_table_its_children_belong_to (self , table_fixture ):
64- table = table_fixture
65- assert table .table is table
66-
67- def it_knows_its_column_count_to_help (self , column_count_fixture ):
68- table , expected_value = column_count_fixture
69- column_count = table ._column_count
70- assert column_count == expected_value
71-
72- def it_provides_access_to_the_table_rows (self , table ):
73- rows = table .rows
74- assert isinstance (rows , _Rows )
75-
76- def it_provides_access_to_the_table_columns (self , table ):
77- columns = table .columns
78- assert isinstance (columns , _Columns )
79-
80- def it_provides_access_to_a_cell_by_row_and_col_indices (self , table ):
81- for row_idx in range (2 ):
82- for col_idx in range (2 ):
83- cell = table .cell (row_idx , col_idx )
84- assert isinstance (cell , _Cell )
85- tr = table ._tbl .tr_lst [row_idx ]
86- tc = tr .tc_lst [col_idx ]
87- assert tc is cell ._tc
88-
89- def it_provides_access_to_the_cells_in_a_column (self , col_cells_fixture ):
90- table , column_idx , expected_cells = col_cells_fixture
91- column_cells = table .column_cells (column_idx )
92- assert column_cells == expected_cells
93-
94- def it_provides_access_to_the_cells_in_a_row (self , row_cells_fixture ):
95- table , row_idx , expected_cells = row_cells_fixture
96- row_cells = table .row_cells (row_idx )
97- assert row_cells == expected_cells
98-
99- def it_can_add_a_row (self , add_row_fixture ):
100- table , expected_xml = add_row_fixture
101- row = table .add_row ()
102- assert table ._tbl .xml == expected_xml
103- assert isinstance (row , _Row )
104- assert row ._tr is table ._tbl .tr_lst [- 1 ]
105- assert row ._parent is table
106-
107- def it_can_add_a_column (self , add_column_fixture ):
108- table , width , expected_xml = add_column_fixture
109- column = table .add_column (width )
110- assert table ._tbl .xml == expected_xml
111- assert isinstance (column , _Column )
112- assert column ._gridCol is table ._tbl .tblGrid .gridCol_lst [- 1 ]
113- assert column ._parent is table
114-
115110 def it_provides_access_to_its_cells_to_help (self , cells_fixture ):
116111 table , cell_count , unique_count , matches = cells_fixture
117112 cells = table ._cells
@@ -122,6 +117,11 @@ def it_provides_access_to_its_cells_to_help(self, cells_fixture):
122117 for idx in matching_idxs [1 :]:
123118 assert cells [idx ] is cells [comparator_idx ]
124119
120+ def it_knows_its_column_count_to_help (self , column_count_fixture ):
121+ table , expected_value = column_count_fixture
122+ column_count = table ._column_count
123+ assert column_count == expected_value
124+
125125 # fixtures -------------------------------------------------------
126126
127127 @pytest .fixture
0 commit comments