Skip to content

Commit 0d75afa

Browse files
committed
TST: remove 'yield' generated tests
pytest no longer supports them. Did this by just calling the helper functions in-line. It does make the tests bigger, but this changes the testing code in the minimal way possible.
1 parent 5860695 commit 0d75afa

File tree

1 file changed

+49
-40
lines changed

1 file changed

+49
-40
lines changed

test_cycler.py

Lines changed: 49 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -39,62 +39,71 @@ def test_creation(c):
3939
_cycler_helper(c, 3, ['c'], [['r', 'g', 'b']])
4040

4141

42-
def test_compose():
42+
def test_add():
4343
c1 = cycler(c='rgb')
4444
c2 = cycler(lw=range(3))
45-
c3 = cycler(lw=range(15))
4645
# addition
47-
yield _cycler_helper, c1+c2, 3, ['c', 'lw'], [list('rgb'), range(3)]
48-
yield _cycler_helper, c2+c1, 3, ['c', 'lw'], [list('rgb'), range(3)]
49-
yield _cycles_equal, c2+c1, c1+c2
46+
_cycler_helper(c1+c2, 3, ['c', 'lw'], [list('rgb'), range(3)])
47+
_cycler_helper(c2+c1, 3, ['c', 'lw'], [list('rgb'), range(3)])
48+
_cycles_equal(c2+c1, c1+c2)
49+
50+
51+
def test_add_len_mismatch():
5052
# miss-matched add lengths
53+
c1 = cycler(c='rgb')
54+
c3 = cycler(lw=range(15))
5155
with pytest.raises(ValueError):
5256
c1 + c3
5357
with pytest.raises(ValueError):
5458
c3 + c1
5559

60+
61+
def test_prod():
62+
c1 = cycler(c='rgb')
63+
c2 = cycler(lw=range(3))
64+
c3 = cycler(lw=range(15))
5665
# multiplication
5766
target = zip(*product(list('rgb'), range(3)))
58-
yield (_cycler_helper, c1 * c2, 9, ['c', 'lw'], target)
67+
_cycler_helper(c1 * c2, 9, ['c', 'lw'], target)
5968

6069
target = zip(*product(range(3), list('rgb')))
61-
yield (_cycler_helper, c2 * c1, 9, ['lw', 'c'], target)
70+
_cycler_helper(c2 * c1, 9, ['lw', 'c'], target)
6271

6372
target = zip(*product(range(15), list('rgb')))
64-
yield (_cycler_helper, c3 * c1, 45, ['lw', 'c'], target)
73+
_cycler_helper(c3 * c1, 45, ['lw', 'c'], target)
6574

6675

6776
def test_inplace():
6877
c1 = cycler(c='rgb')
6978
c2 = cycler(lw=range(3))
7079
c2 += c1
71-
yield _cycler_helper, c2, 3, ['c', 'lw'], [list('rgb'), range(3)]
80+
_cycler_helper(c2, 3, ['c', 'lw'], [list('rgb'), range(3)])
7281

7382
c3 = cycler(c='rgb')
7483
c4 = cycler(lw=range(3))
7584
c3 *= c4
7685
target = zip(*product(list('rgb'), range(3)))
77-
yield (_cycler_helper, c3, 9, ['c', 'lw'], target)
86+
_cycler_helper(c3, 9, ['c', 'lw'], target)
7887

7988

8089
def test_constructor():
8190
c1 = cycler(c='rgb')
8291
c2 = cycler(ec=c1)
83-
yield _cycler_helper, c1+c2, 3, ['c', 'ec'], [['r', 'g', 'b']]*2
92+
_cycler_helper(c1+c2, 3, ['c', 'ec'], [['r', 'g', 'b']]*2)
8493
c3 = cycler(c=c1)
85-
yield _cycler_helper, c3+c2, 3, ['c', 'ec'], [['r', 'g', 'b']]*2
94+
_cycler_helper(c3+c2, 3, ['c', 'ec'], [['r', 'g', 'b']]*2)
8695
# Using a non-string hashable
8796
c4 = cycler(1, range(3))
88-
yield _cycler_helper, c4+c1, 3, [1, 'c'], [range(3), ['r', 'g', 'b']]
97+
_cycler_helper(c4+c1, 3, [1, 'c'], [range(3), ['r', 'g', 'b']])
8998

9099
# addition using cycler()
91-
yield (_cycler_helper, cycler(c='rgb', lw=range(3)),
92-
3, ['c', 'lw'], [list('rgb'), range(3)])
93-
yield (_cycler_helper, cycler(lw=range(3), c='rgb'),
94-
3, ['c', 'lw'], [list('rgb'), range(3)])
100+
_cycler_helper(cycler(c='rgb', lw=range(3)),
101+
3, ['c', 'lw'], [list('rgb'), range(3)])
102+
_cycler_helper(cycler(lw=range(3), c='rgb'),
103+
3, ['c', 'lw'], [list('rgb'), range(3)])
95104
# Purposely mixing them
96-
yield (_cycler_helper, cycler(c=range(3), lw=c1),
97-
3, ['c', 'lw'], [range(3), list('rgb')])
105+
_cycler_helper(cycler(c=range(3), lw=c1),
106+
3, ['c', 'lw'], [range(3), list('rgb')])
98107

99108

100109
def test_failures():
@@ -116,24 +125,24 @@ def test_simplify():
116125
c1 = cycler(c='rgb')
117126
c2 = cycler(ec=c1)
118127
for c in [c1 * c2, c2 * c1, c1 + c2]:
119-
yield _cycles_equal, c, c.simplify()
128+
_cycles_equal(c, c.simplify())
120129

121130

122131
def test_multiply():
123132
c1 = cycler(c='rgb')
124-
yield _cycler_helper, 2*c1, 6, ['c'], ['rgb'*2]
133+
_cycler_helper(2*c1, 6, ['c'], ['rgb'*2])
125134

126135
c2 = cycler(ec=c1)
127136
c3 = c1 * c2
128137

129-
yield _cycles_equal, 2*c3, c3*2
138+
_cycles_equal(2*c3, c3*2)
130139

131140

132141
def test_mul_fails():
133142
c1 = cycler(c='rgb')
134-
pytest.raises(TypeError, mul, c1, 2.0)
135-
pytest.raises(TypeError, mul, c1, 'a')
136-
pytest.raises(TypeError, mul, c1, [])
143+
pytest.raises(TypeError, mul, c1, 2.0)
144+
pytest.raises(TypeError, mul, c1, 'a')
145+
pytest.raises(TypeError, mul, c1, [])
137146

138147

139148
def test_getitem():
@@ -143,7 +152,7 @@ def test_getitem():
143152
slice(None, None, -1),
144153
slice(1, 5, None),
145154
slice(0, 5, 2)):
146-
yield _cycles_equal, c1[slc], cycler(3, widths[slc])
155+
_cycles_equal(c1[slc], cycler(3, widths[slc]))
147156

148157

149158
def test_fail_getime():
@@ -166,14 +175,14 @@ def test_repr():
166175
c_sum_rpr = "(cycler('c', ['r', 'g', 'b']) + cycler('3rd', [0, 1, 2]))"
167176
c_prod_rpr = "(cycler('c', ['r', 'g', 'b']) * cycler('3rd', [0, 1, 2]))"
168177

169-
yield _repr_tester_helper, '__repr__', c + c2, c_sum_rpr
170-
yield _repr_tester_helper, '__repr__', c * c2, c_prod_rpr
178+
_repr_tester_helper('__repr__', c + c2, c_sum_rpr)
179+
_repr_tester_helper('__repr__', c * c2, c_prod_rpr)
171180

172181
sum_html = "<table><th>'3rd'</th><th>'c'</th><tr><td>0</td><td>'r'</td></tr><tr><td>1</td><td>'g'</td></tr><tr><td>2</td><td>'b'</td></tr></table>"
173182
prod_html = "<table><th>'3rd'</th><th>'c'</th><tr><td>0</td><td>'r'</td></tr><tr><td>1</td><td>'r'</td></tr><tr><td>2</td><td>'r'</td></tr><tr><td>0</td><td>'g'</td></tr><tr><td>1</td><td>'g'</td></tr><tr><td>2</td><td>'g'</td></tr><tr><td>0</td><td>'b'</td></tr><tr><td>1</td><td>'b'</td></tr><tr><td>2</td><td>'b'</td></tr></table>"
174183

175-
yield _repr_tester_helper, '_repr_html_', c + c2, sum_html
176-
yield _repr_tester_helper, '_repr_html_', c * c2, prod_html
184+
_repr_tester_helper('_repr_html_', c + c2, sum_html)
185+
_repr_tester_helper('_repr_html_', c * c2, prod_html)
177186

178187

179188
def test_call():
@@ -266,17 +275,17 @@ def _eq_test_helper(a, b, res):
266275
def test_eq():
267276
a = cycler(c='rgb')
268277
b = cycler(c='rgb')
269-
yield _eq_test_helper, a, b, True
270-
yield _eq_test_helper, a, b[::-1], False
278+
_eq_test_helper(a, b, True)
279+
_eq_test_helper(a, b[::-1], False)
271280
c = cycler(lw=range(3))
272-
yield _eq_test_helper, a+c, c+a, True
273-
yield _eq_test_helper, a+c, c+b, True
274-
yield _eq_test_helper, a*c, c*a, False
275-
yield _eq_test_helper, a, c, False
281+
_eq_test_helper(a+c, c+a, True)
282+
_eq_test_helper(a+c, c+b, True)
283+
_eq_test_helper(a*c, c*a, False)
284+
_eq_test_helper(a, c, False)
276285
d = cycler(c='ymk')
277-
yield _eq_test_helper, b, d, False
286+
_eq_test_helper(b, d, False)
278287
e = cycler(c='orange')
279-
yield _eq_test_helper, b, e, False
288+
_eq_test_helper(b, e, False)
280289

281290

282291
def test_cycler_exceptions():
@@ -325,15 +334,15 @@ def test_by_key_add():
325334
cy = cycler(c=input_dict['c']) + cycler(lw=input_dict['lw'])
326335
res = cy.by_key()
327336
assert res == input_dict
328-
yield _by_key_helper, cy
337+
_by_key_helper(cy)
329338

330339

331340
def test_by_key_mul():
332341
input_dict = dict(c=list('rg'), lw=[1, 2, 3])
333342
cy = cycler(c=input_dict['c']) * cycler(lw=input_dict['lw'])
334343
res = cy.by_key()
335344
assert input_dict['lw'] * len(input_dict['c']) == res['lw']
336-
yield _by_key_helper, cy
345+
_by_key_helper(cy)
337346

338347

339348
def test_contains():

0 commit comments

Comments
 (0)