File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,6 +27,14 @@ def add_run(self):
2727 r = self ._p .add_r ()
2828 return Run (r )
2929
30+ @property
31+ def runs (self ):
32+ """
33+ Sequence of |Run| instances corresponding to the <w:r> elements in
34+ this paragraph.
35+ """
36+ return tuple ([Run (r ) for r in self ._p .r_elms ])
37+
3038
3139class Run (object ):
3240 """
Original file line number Diff line number Diff line change 1414
1515import pytest
1616
17- from mock import create_autospec , Mock
17+ from mock import call , create_autospec , Mock
1818
1919from .unitutil import class_mock
2020
@@ -25,6 +25,19 @@ class DescribeParagraph(object):
2525 def Run_ (self , request ):
2626 return class_mock ('docx.text.Run' , request )
2727
28+ def it_has_a_sequence_of_the_runs_it_contains (self , Run_ ):
29+ p_elm = Mock (name = 'p_elm' )
30+ r1 , r2 = (Mock (name = 'r1' ), Mock (name = 'r2' ))
31+ R1 , R2 = (Mock (name = 'Run1' ), Mock (name = 'Run2' ))
32+ p_elm .r_elms = [r1 , r2 ]
33+ p = Paragraph (p_elm )
34+ Run_ .side_effect = [R1 , R2 ]
35+ # exercise ---------------------
36+ runs = p .runs
37+ # verify -----------------------
38+ assert Run_ .mock_calls == [call (r1 ), call (r2 )]
39+ assert runs == (R1 , R2 )
40+
2841 def it_can_add_a_run_to_itself (self , Run_ ):
2942 # mockery ----------------------
3043 p_elm = create_autospec (CT_P )
You can’t perform that action at this time.
0 commit comments