88 absolute_import , division , print_function , unicode_literals
99)
1010
11- from docx .enum .text import WD_BREAK , WD_UNDERLINE
11+ from docx .enum .text import WD_ALIGN_PARAGRAPH , WD_BREAK , WD_UNDERLINE
1212from docx .oxml import OxmlElement
1313from docx .oxml .ns import qn
1414from docx .oxml .text import CT_P , CT_R
1818
1919from .oxml .parts .unitdata .document import a_body
2020from .oxml .unitdata .text import (
21- a_b , a_bCs , a_br , a_caps , a_cr , a_cs , a_dstrike , a_p , a_pPr , a_pStyle ,
22- a_shadow , a_smallCaps , a_snapToGrid , a_specVanish , a_strike , a_t , a_tab ,
23- a_u , a_vanish , a_webHidden , an_emboss , an_i , an_iCs , an_imprint ,
24- an_oMath , a_noProof , an_outline , an_r , an_rPr , an_rStyle , an_rtl
21+ a_b , a_bCs , a_br , a_caps , a_cr , a_cs , a_dstrike , a_jc , a_p , a_pPr ,
22+ a_pStyle , a_shadow , a_smallCaps , a_snapToGrid , a_specVanish , a_strike ,
23+ a_t , a_tab , a_u , a_vanish , a_webHidden , an_emboss , an_i , an_iCs ,
24+ an_imprint , an_oMath , a_noProof , an_outline , an_r , an_rPr , an_rStyle ,
25+ an_rtl
2526)
2627from .unitutil import call , class_mock , instance_mock , Mock
2728
@@ -41,6 +42,10 @@ def it_can_add_a_run_to_itself(self, add_run_fixture):
4142 assert isinstance (run , Run )
4243 assert run ._r is paragraph ._p .r_lst [0 ]
4344
45+ def it_knows_its_alignment_value (self , alignment_get_fixture ):
46+ paragraph , expected_value = alignment_get_fixture
47+ assert paragraph .alignment == expected_value
48+
4449 def it_knows_its_paragraph_style (self ):
4550 cases = (
4651 (Mock (name = 'p_elm' , style = 'foobar' ), 'foobar' ),
@@ -102,6 +107,19 @@ def add_run_fixture(self, request, paragraph):
102107 expected_xml = a_p ().with_nsdecls ().with_child (r_bldr ).xml ()
103108 return paragraph , text , style , expected_xml
104109
110+ @pytest .fixture (params = [
111+ ('center' , WD_ALIGN_PARAGRAPH .CENTER ),
112+ (None , None ),
113+ ])
114+ def alignment_get_fixture (self , request ):
115+ jc_val , expected_alignment_value = request .param
116+ p_bldr = a_p ().with_nsdecls ()
117+ if jc_val is not None :
118+ p_bldr .with_child (a_pPr ().with_child (a_jc ().with_val (jc_val )))
119+ p = p_bldr .element
120+ paragraph = Paragraph (p )
121+ return paragraph , expected_alignment_value
122+
105123 @pytest .fixture
106124 def clear_fixture (self , request ):
107125 """
0 commit comments