|
1 | 1 | # encoding: utf-8 |
2 | 2 |
|
3 | | -""" |
4 | | -Test suite for the docx.table module |
5 | | -""" |
| 3 | +"""Test suite for the docx.table module""" |
6 | 4 |
|
7 | 5 | from __future__ import absolute_import, print_function, unicode_literals |
8 | 6 |
|
@@ -344,6 +342,11 @@ def it_knows_its_vertical_alignment(self, alignment_get_fixture): |
344 | 342 | vertical_alignment = cell.vertical_alignment |
345 | 343 | assert vertical_alignment == expected_value |
346 | 344 |
|
| 345 | + def it_can_change_its_vertical_alignment(self, alignment_set_fixture): |
| 346 | + cell, new_value, expected_xml = alignment_set_fixture |
| 347 | + cell.vertical_alignment = new_value |
| 348 | + assert cell._element.xml == expected_xml |
| 349 | + |
347 | 350 | def it_knows_its_width_in_EMU(self, width_get_fixture): |
348 | 351 | cell, expected_width = width_get_fixture |
349 | 352 | assert cell.width == expected_width |
@@ -428,6 +431,26 @@ def alignment_get_fixture(self, request): |
428 | 431 | cell = _Cell(element(tc_cxml), None) |
429 | 432 | return cell, expected_value |
430 | 433 |
|
| 434 | + @pytest.fixture(params=[ |
| 435 | + ('w:tc', WD_ALIGN_VERTICAL.TOP, |
| 436 | + 'w:tc/w:tcPr/w:vAlign{w:val=top}'), |
| 437 | + ('w:tc/w:tcPr', WD_ALIGN_VERTICAL.CENTER, |
| 438 | + 'w:tc/w:tcPr/w:vAlign{w:val=center}'), |
| 439 | + ('w:tc/w:tcPr/w:vAlign{w:val=center}', WD_ALIGN_VERTICAL.BOTTOM, |
| 440 | + 'w:tc/w:tcPr/w:vAlign{w:val=bottom}'), |
| 441 | + ('w:tc/w:tcPr/w:vAlign{w:val=center}', None, |
| 442 | + 'w:tc/w:tcPr'), |
| 443 | + ('w:tc', None, |
| 444 | + 'w:tc/w:tcPr'), |
| 445 | + ('w:tc/w:tcPr', None, |
| 446 | + 'w:tc/w:tcPr'), |
| 447 | + ]) |
| 448 | + def alignment_set_fixture(self, request): |
| 449 | + cxml, new_value, expected_cxml = request.param |
| 450 | + cell = _Cell(element(cxml), None) |
| 451 | + expected_xml = xml(expected_cxml) |
| 452 | + return cell, new_value, expected_xml |
| 453 | + |
431 | 454 | @pytest.fixture |
432 | 455 | def merge_fixture(self, tc_, tc_2_, parent_, merged_tc_): |
433 | 456 | cell, other_cell = _Cell(tc_, parent_), _Cell(tc_2_, parent_) |
|
0 commit comments