|
| 1 | +# encoding: utf-8 |
| 2 | + |
| 3 | +""" |
| 4 | +Test suite for the docx.section module |
| 5 | +""" |
| 6 | + |
| 7 | +from __future__ import absolute_import, print_function, unicode_literals |
| 8 | + |
| 9 | +import pytest |
| 10 | + |
| 11 | +from docx.enum.section import WD_SECTION |
| 12 | +from docx.section import Section |
| 13 | + |
| 14 | +from .oxml.unitdata.section import a_sectPr, a_type |
| 15 | + |
| 16 | + |
| 17 | +class DescribeSection(object): |
| 18 | + |
| 19 | + def it_knows_its_start_type(self, start_type_fixture): |
| 20 | + section, expected_start_type = start_type_fixture |
| 21 | + assert section.start_type is expected_start_type |
| 22 | + |
| 23 | + # fixtures ------------------------------------------------------- |
| 24 | + |
| 25 | + @pytest.fixture(params=[ |
| 26 | + (None, WD_SECTION.NEW_PAGE), |
| 27 | + ('continuous', WD_SECTION.CONTINUOUS), |
| 28 | + ('nextPage', WD_SECTION.NEW_PAGE), |
| 29 | + ('oddPage', WD_SECTION.ODD_PAGE), |
| 30 | + ('evenPage', WD_SECTION.EVEN_PAGE), |
| 31 | + ('nextColumn', WD_SECTION.NEW_COLUMN), |
| 32 | + ]) |
| 33 | + def start_type_fixture(self, request): |
| 34 | + type_val, expected_start_type = request.param |
| 35 | + sectPr_bldr = a_sectPr().with_nsdecls() |
| 36 | + if type_val is not None: |
| 37 | + sectPr_bldr.with_child(a_type().with_val(type_val)) |
| 38 | + sectPr = sectPr_bldr.element |
| 39 | + section = Section(sectPr) |
| 40 | + return section, expected_start_type |
0 commit comments