@@ -153,31 +153,24 @@ def test_fail_getime():
153
153
pytest .raises (ValueError , Cycler .__getitem__ , c1 , [0 , 1 ])
154
154
155
155
156
- def _repr_tester_helper (rpr_func , cyc , target_repr ):
157
- test_repr = getattr (cyc , rpr_func )()
158
-
159
- assert str (test_repr ) == str (target_repr )
160
-
161
-
162
156
def test_repr ():
163
157
c = cycler (c = 'rgb' )
164
158
# Using an identifier that would be not valid as a kwarg
165
159
c2 = cycler ('3rd' , range (3 ))
166
160
167
- c_sum_rpr = "(cycler('c', ['r', 'g', 'b']) + cycler('3rd', [0, 1, 2]))"
168
- c_prod_rpr = "(cycler('c', ['r', 'g', 'b']) * cycler('3rd', [0, 1, 2]))"
169
-
170
- _repr_tester_helper ('__repr__' , c + c2 , c_sum_rpr )
171
- _repr_tester_helper ('__repr__' , c * c2 , c_prod_rpr )
161
+ assert repr (c + c2 ) == (
162
+ "(cycler('c', ['r', 'g', 'b']) + cycler('3rd', [0, 1, 2]))" )
163
+ assert repr (c * c2 ) == (
164
+ "(cycler('c', ['r', 'g', 'b']) * cycler('3rd', [0, 1, 2]))" )
172
165
173
- sum_html = (
166
+ assert ( c + c2 ). _repr_html_ () = = (
174
167
"<table>"
175
168
"<th>'3rd'</th><th>'c'</th>"
176
169
"<tr><td>0</td><td>'r'</td></tr>"
177
170
"<tr><td>1</td><td>'g'</td></tr>"
178
171
"<tr><td>2</td><td>'b'</td></tr>"
179
172
"</table>" )
180
- prod_html = (
173
+ assert ( c * c2 ). _repr_html_ () = = (
181
174
"<table>"
182
175
"<th>'3rd'</th><th>'c'</th>"
183
176
"<tr><td>0</td><td>'r'</td></tr>"
@@ -191,9 +184,6 @@ def test_repr():
191
184
"<tr><td>2</td><td>'b'</td></tr>"
192
185
"</table>" )
193
186
194
- _repr_tester_helper ('_repr_html_' , c + c2 , sum_html )
195
- _repr_tester_helper ('_repr_html_' , c * c2 , prod_html )
196
-
197
187
198
188
def test_call ():
199
189
c = cycler (c = 'rgb' )
@@ -276,27 +266,20 @@ def test_keychange():
276
266
pytest .raises (KeyError , Cycler .change_key , c , 'c' , 'foobar' )
277
267
278
268
279
- def _eq_test_helper (a , b , res ):
280
- if res :
281
- assert a == b
282
- else :
283
- assert a != b
284
-
285
-
286
269
def test_eq ():
287
270
a = cycler (c = 'rgb' )
288
271
b = cycler (c = 'rgb' )
289
- _eq_test_helper ( a , b , True )
290
- _eq_test_helper ( a , b [::- 1 ], False )
272
+ assert a == b
273
+ assert a != b [::- 1 ]
291
274
c = cycler (lw = range (3 ))
292
- _eq_test_helper ( a + c , c + a , True )
293
- _eq_test_helper ( a + c , c + b , True )
294
- _eq_test_helper ( a * c , c * a , False )
295
- _eq_test_helper ( a , c , False )
275
+ assert a + c == c + a
276
+ assert a + c == c + b
277
+ assert a * c != c * a
278
+ assert a != c
296
279
d = cycler (c = 'ymk' )
297
- _eq_test_helper ( b , d , False )
280
+ assert b != d
298
281
e = cycler (c = 'orange' )
299
- _eq_test_helper ( b , e , False )
282
+ assert b != e
300
283
301
284
302
285
def test_cycler_exceptions ():
0 commit comments