Skip to content

Commit 70b580e

Browse files
author
Steve Canny
committed
para: reposition a couple test fixtures
No code changes.
1 parent 70f0605 commit 70b580e

File tree

3 files changed

+27
-27
lines changed

3 files changed

+27
-27
lines changed

features/steps/paragraph.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,7 @@ def given_a_paragraph_with_content_and_formatting(context):
4747

4848
@when('I add a run to the paragraph')
4949
def when_add_new_run_to_paragraph(context):
50-
context.r = context.p.add_run()
51-
52-
53-
@when('I add text to the run')
54-
def when_I_add_text_to_the_run(context):
55-
context.r.add_text(test_text)
50+
context.run = context.p.add_run()
5651

5752

5853
@when('I clear the paragraph content')

features/steps/text.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ def when_I_add_a_tab(context):
113113
context.run.add_tab()
114114

115115

116+
@when('I add text to the run')
117+
def when_I_add_text_to_the_run(context):
118+
context.run.add_text(test_text)
119+
120+
116121
@when('I assign mixed text to the text property')
117122
def when_I_assign_mixed_text_to_the_text_property(context):
118123
context.run.text = 'abc\tdef\nghi\rjkl'

tests/test_text.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ def it_can_set_its_paragraph_style(self):
6161
p.style = style
6262
assert p_elm.style == expected_setting
6363

64-
def it_knows_the_text_it_contains(self, text_prop_fixture):
65-
p, expected_text = text_prop_fixture
66-
assert p.text == expected_text
64+
def it_knows_the_text_it_contains(self, text_get_fixture):
65+
paragraph, expected_text = text_get_fixture
66+
assert paragraph.text == expected_text
6767

6868
def it_can_insert_a_paragraph_before_itself(self, insert_before_fixture):
6969
paragraph, text, style, body, expected_xml = insert_before_fixture
@@ -135,6 +135,24 @@ def insert_before_fixture(self):
135135
).xml()
136136
return paragraph, text, style, body, expected_xml
137137

138+
@pytest.fixture
139+
def runs_fixture(self, p_, Run_, r_, r_2_, runs_):
140+
paragraph = Paragraph(p_)
141+
run_, run_2_ = runs_
142+
return paragraph, Run_, r_, r_2_, run_, run_2_
143+
144+
@pytest.fixture
145+
def text_get_fixture(self):
146+
p = (
147+
a_p().with_nsdecls().with_child(
148+
an_r().with_child(
149+
a_t().with_text('foo'))).with_child(
150+
an_r().with_child(
151+
a_t().with_text(' de bar')))
152+
).element
153+
paragraph = Paragraph(p)
154+
return paragraph, 'foo de bar'
155+
138156
# fixture components ---------------------------------------------
139157

140158
@pytest.fixture
@@ -167,24 +185,6 @@ def runs_(self, request):
167185
run_2_ = instance_mock(request, Run, name='run_2_')
168186
return run_, run_2_
169187

170-
@pytest.fixture
171-
def runs_fixture(self, p_, Run_, r_, r_2_, runs_):
172-
paragraph = Paragraph(p_)
173-
run_, run_2_ = runs_
174-
return paragraph, Run_, r_, r_2_, run_, run_2_
175-
176-
@pytest.fixture
177-
def text_prop_fixture(self):
178-
p = (
179-
a_p().with_nsdecls().with_child(
180-
an_r().with_child(
181-
a_t().with_text('foo'))).with_child(
182-
an_r().with_child(
183-
a_t().with_text(' de bar')))
184-
).element
185-
paragraph = Paragraph(p)
186-
return paragraph, 'foo de bar'
187-
188188

189189
class DescribeRun(object):
190190

0 commit comments

Comments
 (0)