|
10 | 10 |
|
11 | 11 | from docx.enum.style import WD_STYLE_TYPE |
12 | 12 | from docx.enum.table import ( |
13 | | - WD_ROW_HEIGHT, WD_TABLE_ALIGNMENT, WD_TABLE_DIRECTION |
| 13 | + WD_ALIGN_VERTICAL, WD_ROW_HEIGHT, WD_TABLE_ALIGNMENT, WD_TABLE_DIRECTION |
14 | 14 | ) |
15 | 15 | from docx.oxml import parse_xml |
16 | 16 | from docx.oxml.table import CT_Tc |
@@ -339,6 +339,11 @@ def it_can_replace_its_content_with_a_string_of_text( |
339 | 339 | cell.text = text |
340 | 340 | assert cell._tc.xml == expected_xml |
341 | 341 |
|
| 342 | + def it_knows_its_vertical_alignment(self, alignment_get_fixture): |
| 343 | + cell, expected_value = alignment_get_fixture |
| 344 | + vertical_alignment = cell.vertical_alignment |
| 345 | + assert vertical_alignment == expected_value |
| 346 | + |
342 | 347 | def it_knows_its_width_in_EMU(self, width_get_fixture): |
343 | 348 | cell, expected_width = width_get_fixture |
344 | 349 | assert cell.width == expected_width |
@@ -412,6 +417,17 @@ def add_table_fixture(self, request): |
412 | 417 | expected_xml = snippet_seq('new-tbl')[1] |
413 | 418 | return cell, expected_xml |
414 | 419 |
|
| 420 | + @pytest.fixture(params=[ |
| 421 | + ('w:tc', None), |
| 422 | + ('w:tc/w:tcPr', None), |
| 423 | + ('w:tc/w:tcPr/w:vAlign{w:val=bottom}', WD_ALIGN_VERTICAL.BOTTOM), |
| 424 | + ('w:tc/w:tcPr/w:vAlign{w:val=top}', WD_ALIGN_VERTICAL.TOP), |
| 425 | + ]) |
| 426 | + def alignment_get_fixture(self, request): |
| 427 | + tc_cxml, expected_value = request.param |
| 428 | + cell = _Cell(element(tc_cxml), None) |
| 429 | + return cell, expected_value |
| 430 | + |
415 | 431 | @pytest.fixture |
416 | 432 | def merge_fixture(self, tc_, tc_2_, parent_, merged_tc_): |
417 | 433 | cell, other_cell = _Cell(tc_, parent_), _Cell(tc_2_, parent_) |
|
0 commit comments