99import pytest
1010
1111from docx .enum .style import WD_STYLE_TYPE
12- from docx .enum .table import WD_TABLE_ALIGNMENT , WD_TABLE_DIRECTION
12+ from docx .enum .table import (
13+ WD_ROW_HEIGHT , WD_TABLE_ALIGNMENT , WD_TABLE_DIRECTION
14+ )
1315from docx .oxml import parse_xml
1416from docx .oxml .table import CT_Tc
1517from docx .parts .document import DocumentPart
@@ -651,6 +653,10 @@ def table_(self, request):
651653
652654class Describe_Row (object ):
653655
656+ def it_knows_its_height_rule (self , height_rule_get_fixture ):
657+ row , expected_rule = height_rule_get_fixture
658+ assert row .height_rule == expected_rule
659+
654660 def it_provides_access_to_its_cells (self , cells_fixture ):
655661 row , row_idx , expected_cells = cells_fixture
656662 cells = row .cells
@@ -675,6 +681,21 @@ def cells_fixture(self, _index_, table_prop_, table_):
675681 table_ .row_cells .return_value = list (expected_cells )
676682 return row , row_idx , expected_cells
677683
684+ @pytest .fixture (params = [
685+ ('w:tr' , None ),
686+ ('w:tr/w:trPr' , None ),
687+ ('w:tr/w:trPr/w:trHeight{w:val=0, w:hRule=auto}' ,
688+ WD_ROW_HEIGHT .AUTO ),
689+ ('w:tr/w:trPr/w:trHeight{w:val=1440, w:hRule=atLeast}' ,
690+ WD_ROW_HEIGHT .AT_LEAST ),
691+ ('w:tr/w:trPr/w:trHeight{w:val=2880, w:hRule=exact}' ,
692+ WD_ROW_HEIGHT .EXACTLY ),
693+ ])
694+ def height_rule_get_fixture (self , request ):
695+ tr_cxml , expected_rule = request .param
696+ row = _Row (element (tr_cxml ), None )
697+ return row , expected_rule
698+
678699 @pytest .fixture
679700 def idx_fixture (self ):
680701 tbl = element ('w:tbl/(w:tr,w:tr,w:tr)' )
0 commit comments