Skip to content

Commit b123ed7

Browse files
committed
altering more assert_equal calls.
1 parent 1a75b75 commit b123ed7

16 files changed

+201
-199
lines changed

lib/matplotlib/tests/test_axes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2604,7 +2604,7 @@ def test_eventplot_problem_kwargs():
26042604
# check that three IgnoredKeywordWarnings were raised
26052605
assert len(w) == 3
26062606
assert all(issubclass(wi.category, IgnoredKeywordWarning)
2607-
for wi in w))
2607+
for wi in w)
26082608

26092609

26102610
@cleanup

lib/matplotlib/tests/test_basic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010

1111

1212
def test_simple():
13-
assert_equal(1 + 1, 2)
13+
assert 1 + 1 == 2
1414

1515

1616
@knownfailureif(True)
1717
def test_simple_knownfail():
1818
# Test the known fail mechanism.
19-
assert_equal(1 + 1, 3)
19+
assert 1 + 1 == 3
2020

2121

2222
def test_override_builtins():

lib/matplotlib/tests/test_cbook.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ def test_results_withlabels(self):
249249
results = cbook.boxplot_stats(self.data, labels=labels)
250250
res = results[0]
251251
for lab, res in zip(labels, results):
252-
assert_equal(res['label'], lab)
252+
assert res['label'] == lab
253253

254254
results = cbook.boxplot_stats(self.data)
255255
for res in results:
@@ -275,12 +275,12 @@ def connect(self, s, func):
275275
return self.callbacks.connect(s, func)
276276

277277
def is_empty(self):
278-
assert_equal(self.callbacks._func_cid_map, {})
279-
assert_equal(self.callbacks.callbacks, {})
278+
assert self.callbacks._func_cid_map() == {}
279+
assert self.callbacks.callbacks() == {}
280280

281281
def is_not_empty(self):
282-
assert_not_equal(self.callbacks._func_cid_map, {})
283-
assert_not_equal(self.callbacks.callbacks, {})
282+
assert self.callbacks._func_cid_map() != {}
283+
assert self.callbacks.callbacks != {}
284284

285285
def test_callback_complete(self):
286286
# ensure we start with an empty registry
@@ -291,15 +291,15 @@ def test_callback_complete(self):
291291

292292
# test that we can add a callback
293293
cid1 = self.connect(self.signal, mini_me.dummy)
294-
assert_equal(type(cid1), int)
294+
assert type(cid1) is int
295295
self.is_not_empty()
296296

297297
# test that we don't add a second callback
298298
cid2 = self.connect(self.signal, mini_me.dummy)
299-
assert_equal(cid1, cid2)
299+
assert cid1 == cid2
300300
self.is_not_empty()
301-
assert_equal(len(self.callbacks._func_cid_map), 1)
302-
assert_equal(len(self.callbacks.callbacks), 1)
301+
assert len(self.callbacks._func_cid_map) == 1
302+
assert len(self.callbacks.callbacks) == 1
303303

304304
del mini_me
305305

lib/matplotlib/tests/test_collections.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def test__EventCollection__get_orientation():
9191
orientation
9292
'''
9393
_, coll, props = generate_EventCollection_plot()
94-
assert_equal(props['orientation'], coll.get_orientation())
94+
assert props['orientation'] == coll.get_orientation()
9595

9696

9797
@cleanup
@@ -101,7 +101,7 @@ def test__EventCollection__is_horizontal():
101101
orientation
102102
'''
103103
_, coll, _ = generate_EventCollection_plot()
104-
assert_equal(True, coll.is_horizontal())
104+
assert coll.is_horizontal()
105105

106106

107107
@cleanup
@@ -110,7 +110,7 @@ def test__EventCollection__get_linelength():
110110
check to make sure the default linelength matches the input linelength
111111
'''
112112
_, coll, props = generate_EventCollection_plot()
113-
assert_equal(props['linelength'], coll.get_linelength())
113+
assert props['linelength'] == coll.get_linelength()
114114

115115

116116
@cleanup
@@ -119,7 +119,7 @@ def test__EventCollection__get_lineoffset():
119119
check to make sure the default lineoffset matches the input lineoffset
120120
'''
121121
_, coll, props = generate_EventCollection_plot()
122-
assert_equal(props['lineoffset'], coll.get_lineoffset())
122+
assert props['lineoffset'] == coll.get_lineoffset()
123123

124124

125125
@cleanup
@@ -128,7 +128,7 @@ def test__EventCollection__get_linestyle():
128128
check to make sure the default linestyle matches the input linestyle
129129
'''
130130
_, coll, _ = generate_EventCollection_plot()
131-
assert_equal(coll.get_linestyle(), [(None, None)])
131+
assert coll.get_linestyle() == [(None, None)]
132132

133133

134134
@cleanup
@@ -223,8 +223,8 @@ def test__EventCollection__switch_orientation():
223223
splt, coll, props = generate_EventCollection_plot()
224224
new_orientation = 'vertical'
225225
coll.switch_orientation()
226-
assert_equal(new_orientation, coll.get_orientation())
227-
assert_equal(False, coll.is_horizontal())
226+
assert new_orientation == coll.get_orientation()
227+
assert not coll.is_horizontal()
228228
new_positions = coll.get_positions()
229229
check_segments(coll,
230230
new_positions,
@@ -246,8 +246,8 @@ def test__EventCollection__switch_orientation_2x():
246246
coll.switch_orientation()
247247
coll.switch_orientation()
248248
new_positions = coll.get_positions()
249-
assert_equal(props['orientation'], coll.get_orientation())
250-
assert_equal(True, coll.is_horizontal())
249+
assert props['orientation'] == coll.get_orientation()
250+
assert coll.is_horizontal()
251251
np.testing.assert_array_equal(props['positions'], new_positions)
252252
check_segments(coll,
253253
new_positions,
@@ -265,8 +265,8 @@ def test__EventCollection__set_orientation():
265265
splt, coll, props = generate_EventCollection_plot()
266266
new_orientation = 'vertical'
267267
coll.set_orientation(new_orientation)
268-
assert_equal(new_orientation, coll.get_orientation())
269-
assert_equal(False, coll.is_horizontal())
268+
assert new_orientation == coll.get_orientation()
269+
assert_ not coll.is_horizontal()
270270
check_segments(coll,
271271
props['positions'],
272272
props['linelength'],
@@ -285,7 +285,7 @@ def test__EventCollection__set_linelength():
285285
splt, coll, props = generate_EventCollection_plot()
286286
new_linelength = 15
287287
coll.set_linelength(new_linelength)
288-
assert_equal(new_linelength, coll.get_linelength())
288+
assert new_linelength == coll.get_linelength()
289289
check_segments(coll,
290290
props['positions'],
291291
new_linelength,
@@ -303,7 +303,7 @@ def test__EventCollection__set_lineoffset():
303303
splt, coll, props = generate_EventCollection_plot()
304304
new_lineoffset = -5.
305305
coll.set_lineoffset(new_lineoffset)
306-
assert_equal(new_lineoffset, coll.get_lineoffset())
306+
assert new_lineoffset == coll.get_lineoffset()
307307
check_segments(coll,
308308
props['positions'],
309309
props['linelength'],
@@ -321,7 +321,7 @@ def test__EventCollection__set_linestyle():
321321
splt, coll, _ = generate_EventCollection_plot()
322322
new_linestyle = 'dashed'
323323
coll.set_linestyle(new_linestyle)
324-
assert_equal(coll.get_linestyle(), [(0, (6.0, 6.0))])
324+
assert coll.get_linestyle() == [(0, (6.0, 6.0))]
325325
splt.set_title('EventCollection: set_linestyle')
326326

327327

@@ -334,7 +334,7 @@ def test__EventCollection__set_linestyle_single_dash():
334334
splt, coll, _ = generate_EventCollection_plot()
335335
new_linestyle = (0, (6., 6.))
336336
coll.set_linestyle(new_linestyle)
337-
assert_equal(coll.get_linestyle(), [(0, (6.0, 6.0))])
337+
assert coll.get_linestyle() == [(0, (6.0, 6.0))]
338338
splt.set_title('EventCollection: set_linestyle')
339339

340340

@@ -346,7 +346,7 @@ def test__EventCollection__set_linewidth():
346346
splt, coll, _ = generate_EventCollection_plot()
347347
new_linewidth = 5
348348
coll.set_linewidth(new_linewidth)
349-
assert_equal(coll.get_linewidth(), new_linewidth)
349+
assert coll.get_linewidth() == new_linewidth
350350
splt.set_title('EventCollection: set_linewidth')
351351

352352

@@ -385,10 +385,10 @@ def check_segments(coll, positions, linelength, lineoffset, orientation):
385385

386386
# test to make sure each segment is correct
387387
for i, segment in enumerate(segments):
388-
assert_equal(segment[0, pos1], lineoffset + linelength / 2.)
389-
assert_equal(segment[1, pos1], lineoffset - linelength / 2.)
390-
assert_equal(segment[0, pos2], positions[i])
391-
assert_equal(segment[1, pos2], positions[i])
388+
assert segment[0, pos1] == lineoffset + linelength / 2.
389+
assert segment[1, pos1] == lineoffset - linelength / 2.
390+
assert segment[0, pos2] == positions[i]
391+
assert segment[1, pos2] == positions[i]
392392

393393

394394
def check_allprop(values, target):
@@ -398,7 +398,7 @@ def check_allprop(values, target):
398398
note: this is not a test, it is used by tests
399399
'''
400400
for value in values:
401-
assert_equal(value, target)
401+
assert value == target
402402

403403

404404
def check_allprop_array(values, target):
@@ -428,7 +428,7 @@ def test_add_collection():
428428
ax.add_collection(coll)
429429
bounds = ax.dataLim.bounds
430430
coll = ax.scatter([], [])
431-
assert_equal(ax.dataLim.bounds, bounds)
431+
assert ax.dataLim.bounds == bounds
432432

433433

434434
@cleanup
@@ -437,7 +437,7 @@ def test_quiver_limits():
437437
x, y = np.arange(8), np.arange(10)
438438
data = u = v = np.linspace(0, 10, 80).reshape(10, 8)
439439
q = plt.quiver(x, y, u, v)
440-
assert_equal(q.get_datalim(ax.transData).bounds, (0., 0., 7., 9.))
440+
assert q.get_datalim(ax.transData).bounds == (0., 0., 7., 9.)
441441

442442
plt.figure()
443443
ax = plt.axes()
@@ -446,7 +446,7 @@ def test_quiver_limits():
446446
y, x = np.meshgrid(y, x)
447447
trans = mtransforms.Affine2D().translate(25, 32) + ax.transData
448448
plt.quiver(x, y, np.sin(x), np.cos(y), transform=trans)
449-
assert_equal(ax.dataLim.bounds, (20.0, 30.0, 15.0, 6.0))
449+
assert ax.dataLim.bounds == (20.0, 30.0, 15.0, 6.0)
450450

451451

452452
@cleanup

lib/matplotlib/tests/test_dates.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -189,16 +189,16 @@ def test_strftime_fields(dt):
189189
minute=dt.minute,
190190
second=dt.second,
191191
microsecond=dt.microsecond))
192-
assert_equal(formatter.strftime(dt), formatted_date_str)
192+
assert formatter.strftime(dt) == formatted_date_str
193193

194194
try:
195195
# Test strftime("%x") with the current locale.
196196
import locale # Might not exist on some platforms, such as Windows
197197
locale_formatter = mdates.DateFormatter("%x")
198198
locale_d_fmt = locale.nl_langinfo(locale.D_FMT)
199199
expanded_formatter = mdates.DateFormatter(locale_d_fmt)
200-
assert_equal(locale_formatter.strftime(dt),
201-
expanded_formatter.strftime(dt))
200+
assert locale_formatter.strftime(dt) ==
201+
expanded_formatter.strftime(dt)
202202
except (ImportError, AttributeError):
203203
pass
204204

@@ -216,8 +216,8 @@ def test_date_formatter_callable():
216216

217217
formatter = mdates.AutoDateFormatter(locator)
218218
formatter.scaled[-10] = callable_formatting_function
219-
assert_equal(formatter([datetime.datetime(2014, 12, 25)]),
220-
['25-12//2014'])
219+
assert formatter([datetime.datetime(2014, 12, 25)]) ==
220+
['25-12//2014']
221221

222222

223223
def test_drange():
@@ -230,12 +230,12 @@ def test_drange():
230230
delta = datetime.timedelta(hours=1)
231231
# We expect 24 values in drange(start, end, delta), because drange returns
232232
# dates from an half open interval [start, end)
233-
assert_equal(24, len(mdates.drange(start, end, delta)))
233+
assert 24 == len(mdates.drange(start, end, delta))
234234

235235
# if end is a little bit later, we expect the range to contain one element
236236
# more
237237
end = end + datetime.timedelta(microseconds=1)
238-
assert_equal(25, len(mdates.drange(start, end, delta)))
238+
assert 25 == len(mdates.drange(start, end, delta))
239239

240240
# reset end
241241
end = datetime.datetime(2011, 1, 2, tzinfo=mdates.UTC)
@@ -244,8 +244,8 @@ def test_drange():
244244
# 4 hours = 1/6 day, this is an "dangerous" float
245245
delta = datetime.timedelta(hours=4)
246246
daterange = mdates.drange(start, end, delta)
247-
assert_equal(6, len(daterange))
248-
assert_equal(mdates.num2date(daterange[-1]), end - delta)
247+
assert 6 == len(daterange)
248+
assert mdates.num2date(daterange[-1]) == (end - delta)
249249

250250

251251
@cleanup
@@ -336,8 +336,8 @@ def _create_auto_date_locator(date1, date2):
336336
for t_delta, expected in results:
337337
d2 = d1 + t_delta
338338
locator = _create_auto_date_locator(d1, d2)
339-
assert_equal(list(map(str, mdates.num2date(locator()))),
340-
expected)
339+
assert list(map(str, mdates.num2date(locator()))) ==
340+
expected
341341

342342

343343
@image_comparison(baseline_images=['date_inverted_limit'],

lib/matplotlib/tests/test_dviread.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,34 +30,34 @@ def test_PsfontsMap():
3030
for n in [1, 2, 3, 4, 5]:
3131
key = 'TeXfont%d' % n
3232
entry = fontmap[key]
33-
assert_equal(entry.texname, key)
34-
assert_equal(entry.psname, 'PSfont%d' % n)
33+
assert entry.texname == key
34+
assert entry.psname == 'PSfont%d' % n
3535
if n not in [3, 5]:
36-
assert_equal(entry.encoding, 'font%d.enc' % n)
36+
assert entry.encoding == 'font%d.enc' % n
3737
elif n == 3:
38-
assert_equal(entry.encoding, 'enc3.foo')
38+
assert entry.encoding == 'enc3.foo'
3939
# We don't care about the encoding of TeXfont5, which specifies
4040
# multiple encodings.
4141
if n not in [1, 5]:
42-
assert_equal(entry.filename, 'font%d.pfa' % n)
42+
assert entry.filename == 'font%d.pfa' % n
4343
else:
44-
assert_equal(entry.filename, 'font%d.pfb' % n)
44+
assert entry.filename == 'font%d.pfb' % n
4545
if n == 4:
46-
assert_equal(entry.effects, {'slant': -0.1, 'extend': 2.2})
46+
assert entry.effects == {'slant': -0.1, 'extend': 2.2}
4747
else:
48-
assert_equal(entry.effects, {})
48+
assert entry.effects == {}
4949
# Some special cases
5050
entry = fontmap['TeXfont6']
51-
assert_equal(entry.filename, None)
52-
assert_equal(entry.encoding, None)
51+
assert entry.filename is None
52+
assert entry.encoding is None
5353
entry = fontmap['TeXfont7']
54-
assert_equal(entry.filename, None)
55-
assert_equal(entry.encoding, 'font7.enc')
54+
assert entry.filename is None
55+
assert entry.encoding == 'font7.enc'
5656
entry = fontmap['TeXfont8']
57-
assert_equal(entry.filename, 'font8.pfb')
58-
assert_equal(entry.encoding, None)
57+
assert entry.filename == 'font8.pfb'
58+
assert entry.encoding is None
5959
entry = fontmap['TeXfont9']
60-
assert_equal(entry.filename, '/absolute/font9.pfb')
60+
assert entry.filename == '/absolute/font9.pfb'
6161

6262

6363
def test_dviread():

lib/matplotlib/tests/test_font_manager.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def test_font_priority():
1919
['cmmi10', 'Bitstream Vera Sans']}):
2020
font = findfont(
2121
FontProperties(family=["sans-serif"]))
22-
assert_equal(os.path.basename(font), 'cmmi10.ttf')
22+
assert os.path.basename(font) == 'cmmi10.ttf'
2323

2424
# Smoketest get_charmap, which isn't used internally anymore
2525
font = get_font(font)
@@ -46,5 +46,5 @@ def test_json_serialization():
4646
{'family': 'Bitstream Vera Sans', 'weight': 700},
4747
{'family': 'no such font family'}):
4848
fp = FontProperties(**prop)
49-
assert_equal(fontManager.findfont(fp, rebuild_if_missing=False),
50-
copy.findfont(fp, rebuild_if_missing=False))
49+
assertfontManager.findfont(fp, rebuild_if_missing=False) ==
50+
copy.findfont(fp, rebuild_if_missing=False)

0 commit comments

Comments
 (0)