Skip to content

Commit

Permalink
MAINT: Remove self.assertNotEqual from testing (pandas-dev#16176)
Browse files Browse the repository at this point in the history
  • Loading branch information
gfyoung authored and pcluo committed May 22, 2017
1 parent f64025f commit d81d8ee
Show file tree
Hide file tree
Showing 18 changed files with 40 additions and 42 deletions.
2 changes: 1 addition & 1 deletion pandas/tests/frame/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def test_deepcopy(self):
series = cp['A']
series[:] = 10
for idx, value in compat.iteritems(series):
self.assertNotEqual(self.frame['A'][idx], value)
assert self.frame['A'][idx] != value

# ---------------------------------------------------------------------
# Transposing
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/frame/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1890,7 +1890,7 @@ def test_nested_exception(self):
try:
repr(df)
except Exception as e:
self.assertNotEqual(type(e), UnboundLocalError)
assert type(e) != UnboundLocalError

def test_reindex_methods(self):
df = pd.DataFrame({'x': list(range(5))})
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/frame/test_sorting.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ def test_sort_index_inplace(self):
df.sort_index(inplace=True)
expected = frame
assert_frame_equal(df, expected)
self.assertNotEqual(a_id, id(df['A']))
assert a_id != id(df['A'])

df = unordered.copy()
df.sort_index(ascending=False, inplace=True)
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/groupby/test_groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,7 @@ def test_frame_set_name_single(self):
assert result.index.name == 'A'

result = self.df.groupby('A', as_index=False).mean()
self.assertNotEqual(result.index.name, 'A')
assert result.index.name != 'A'

result = grouped.agg(np.mean)
assert result.index.name == 'A'
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def test_constructor(self):
assert index.name == 'name'
tm.assert_numpy_array_equal(arr, index.values)
arr[0] = "SOMEBIGLONGSTRING"
self.assertNotEqual(index[0], "SOMEBIGLONGSTRING")
assert index[0] != "SOMEBIGLONGSTRING"

# what to do here?
# arr = np.array(5.)
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/test_numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ def test_constructor(self):

# this should not change index
arr[0] = val
self.assertNotEqual(new_index[0], val)
assert new_index[0] != val

# interpret list-like
expected = Int64Index([5, 0])
Expand Down
10 changes: 5 additions & 5 deletions pandas/tests/io/formats/test_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ def test_wide_repr(self):
assert "10 rows x %d columns" % (max_cols - 1) in rep_str
set_option('display.expand_frame_repr', True)
wide_repr = repr(df)
self.assertNotEqual(rep_str, wide_repr)
assert rep_str != wide_repr

with option_context('display.width', 120):
wider_repr = repr(df)
Expand All @@ -944,7 +944,7 @@ def test_wide_repr_named(self):
rep_str = repr(df)
set_option('display.expand_frame_repr', True)
wide_repr = repr(df)
self.assertNotEqual(rep_str, wide_repr)
assert rep_str != wide_repr

with option_context('display.width', 150):
wider_repr = repr(df)
Expand All @@ -966,7 +966,7 @@ def test_wide_repr_multiindex(self):
rep_str = repr(df)
set_option('display.expand_frame_repr', True)
wide_repr = repr(df)
self.assertNotEqual(rep_str, wide_repr)
assert rep_str != wide_repr

with option_context('display.width', 150):
wider_repr = repr(df)
Expand All @@ -990,7 +990,7 @@ def test_wide_repr_multiindex_cols(self):
rep_str = repr(df)
set_option('display.expand_frame_repr', True)
wide_repr = repr(df)
self.assertNotEqual(rep_str, wide_repr)
assert rep_str != wide_repr

with option_context('display.width', 150):
wider_repr = repr(df)
Expand All @@ -1006,7 +1006,7 @@ def test_wide_repr_unicode(self):
rep_str = repr(df)
set_option('display.expand_frame_repr', True)
wide_repr = repr(df)
self.assertNotEqual(rep_str, wide_repr)
assert rep_str != wide_repr

with option_context('display.width', 150):
wider_repr = repr(df)
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/io/formats/test_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ def test_deepcopy(self):

self.styler._update_ctx(self.attrs)
self.styler.highlight_max()
self.assertNotEqual(self.styler.ctx, s2.ctx)
assert self.styler.ctx != s2.ctx
assert s2._todo == []
self.assertNotEqual(self.styler._todo, s2._todo)
assert self.styler._todo != s2._todo

def test_clear(self):
s = self.df.style.highlight_max()._compute()
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/io/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_expand_user(self):
filename = '~/sometest'
expanded_name = common._expand_user(filename)

self.assertNotEqual(expanded_name, filename)
assert expanded_name != filename
assert isabs(expanded_name)
assert os.path.expanduser(filename) == expanded_name

Expand Down Expand Up @@ -68,7 +68,7 @@ def test_stringify_path_localpath(self):
def test_get_filepath_or_buffer_with_path(self):
filename = '~/sometest'
filepath_or_buffer, _, _ = common.get_filepath_or_buffer(filename)
self.assertNotEqual(filepath_or_buffer, filename)
assert filepath_or_buffer != filename
assert isabs(filepath_or_buffer)
assert os.path.expanduser(filename) == filepath_or_buffer

Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/scalar/test_period.py
Original file line number Diff line number Diff line change
Expand Up @@ -938,8 +938,8 @@ def test_equal_Raises_Value(self):
self.january1 == self.day

def test_notEqual(self):
self.assertNotEqual(self.january1, 1)
self.assertNotEqual(self.january1, self.february)
assert self.january1 != 1
assert self.january1 != self.february

def test_greater(self):
assert self.february > self.january1
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/scalar/test_timedelta.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ def test_timedelta_hash_equality(self):

# python timedeltas drop ns resolution
ns_td = Timedelta(1, 'ns')
self.assertNotEqual(hash(ns_td), hash(ns_td.to_pytimedelta()))
assert hash(ns_td) != hash(ns_td.to_pytimedelta())

def test_implementation_limits(self):
min_td = Timedelta(Timedelta.min)
Expand Down
10 changes: 5 additions & 5 deletions pandas/tests/scalar/test_timestamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -873,8 +873,8 @@ def test_comparison(self):

other = Timestamp(stamp + 100)

self.assertNotEqual(val, other)
self.assertNotEqual(val, other)
assert val != other
assert val != other
assert val < other
assert val <= other
assert other > val
Expand Down Expand Up @@ -1375,9 +1375,9 @@ def test_timestamp_compare_with_early_datetime(self):
assert not stamp == datetime.min
assert not stamp == datetime(1600, 1, 1)
assert not stamp == datetime(2700, 1, 1)
self.assertNotEqual(stamp, datetime.min)
self.assertNotEqual(stamp, datetime(1600, 1, 1))
self.assertNotEqual(stamp, datetime(2700, 1, 1))
assert stamp != datetime.min
assert stamp != datetime(1600, 1, 1)
assert stamp != datetime(2700, 1, 1)
assert stamp > datetime(1600, 1, 1)
assert stamp >= datetime(1600, 1, 1)
assert stamp < datetime(2700, 1, 1)
Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/series/test_missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1078,8 +1078,8 @@ def test_spline_extrapolate(self):
def test_spline_smooth(self):
tm._skip_if_no_scipy()
s = Series([1, 2, np.nan, 4, 5.1, np.nan, 7])
self.assertNotEqual(s.interpolate(method='spline', order=3, s=0)[5],
s.interpolate(method='spline', order=3)[5])
assert (s.interpolate(method='spline', order=3, s=0)[5] !=
s.interpolate(method='spline', order=3)[5])

def test_spline_interpolation(self):
tm._skip_if_no_scipy()
Expand All @@ -1090,8 +1090,8 @@ def test_spline_interpolation(self):
expected1 = s.interpolate(method='spline', order=1)
assert_series_equal(result1, expected1)

# GH #10633
def test_spline_error(self):
# see gh-10633
tm._skip_if_no_scipy()

s = pd.Series(np.arange(10) ** 2)
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/test_expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def testit():
if op is not None:
result = expr._can_use_numexpr(op, op_str, f, f,
'evaluate')
self.assertNotEqual(result, f._is_mixed_type)
assert result != f._is_mixed_type

result = expr.evaluate(op, op_str, f, f,
use_numexpr=True)
Expand Down Expand Up @@ -336,7 +336,7 @@ def testit():

result = expr._can_use_numexpr(op, op_str, f11, f12,
'evaluate')
self.assertNotEqual(result, f11._is_mixed_type)
assert result != f11._is_mixed_type

result = expr.evaluate(op, op_str, f11, f12,
use_numexpr=True)
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/test_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -1636,7 +1636,7 @@ def test_swapaxes(self):
# this works, but return a copy
result = self.panel.swapaxes('items', 'items')
assert_panel_equal(self.panel, result)
self.assertNotEqual(id(self.panel), id(result))
assert id(self.panel) != id(result)

def test_transpose(self):
with catch_warnings(record=True):
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/test_panel4d.py
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ def test_swapaxes(self):
# this works, but return a copy
result = self.panel4d.swapaxes('items', 'items')
assert_panel4d_equal(self.panel4d, result)
self.assertNotEqual(id(self.panel4d), id(result))
assert id(self.panel4d) != id(result)

def test_update(self):

Expand Down
19 changes: 9 additions & 10 deletions pandas/tests/tseries/test_offsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ def test_eq(self):
offset1 = DateOffset(days=1)
offset2 = DateOffset(days=365)

self.assertNotEqual(offset1, offset2)
assert offset1 != offset2


class TestBusinessDay(Base):
Expand Down Expand Up @@ -775,12 +775,11 @@ def testEQ(self):
for offset in [self.offset1, self.offset2, self.offset3, self.offset4]:
assert offset == offset

self.assertNotEqual(BusinessHour(), BusinessHour(-1))
assert BusinessHour() != BusinessHour(-1)
assert BusinessHour(start='09:00') == BusinessHour()
self.assertNotEqual(BusinessHour(start='09:00'),
BusinessHour(start='09:01'))
self.assertNotEqual(BusinessHour(start='09:00', end='17:00'),
BusinessHour(start='17:00', end='09:01'))
assert BusinessHour(start='09:00') != BusinessHour(start='09:01')
assert (BusinessHour(start='09:00', end='17:00') !=
BusinessHour(start='17:00', end='09:01'))

def test_hash(self):
for offset in [self.offset1, self.offset2, self.offset3, self.offset4]:
Expand Down Expand Up @@ -4362,7 +4361,7 @@ def test_Hour(self):
assert Hour(3) + Hour(2) == Hour(5)
assert Hour(3) - Hour(2) == Hour()

self.assertNotEqual(Hour(4), Hour(1))
assert Hour(4) != Hour(1)

def test_Minute(self):
assertEq(Minute(), datetime(2010, 1, 1), datetime(2010, 1, 1, 0, 1))
Expand All @@ -4374,7 +4373,7 @@ def test_Minute(self):

assert Minute(3) + Minute(2) == Minute(5)
assert Minute(3) - Minute(2) == Minute()
self.assertNotEqual(Minute(5), Minute())
assert Minute(5) != Minute()

def test_Second(self):
assertEq(Second(), datetime(2010, 1, 1), datetime(2010, 1, 1, 0, 0, 1))
Expand Down Expand Up @@ -4464,8 +4463,8 @@ def test_tick_equalities(self):
assert t() == t(1)

# not equals
self.assertNotEqual(t(3), t(2))
self.assertNotEqual(t(3), t(-3))
assert t(3) != t(2)
assert t(3) != t(-3)

def test_tick_operators(self):
for t in self.ticks:
Expand Down
3 changes: 1 addition & 2 deletions pandas/tests/tseries/test_timezones.py
Original file line number Diff line number Diff line change
Expand Up @@ -1191,8 +1191,7 @@ def test_cache_keys_are_distinct_for_pytz_vs_dateutil(self):
if tz_d is None:
# skip timezones that dateutil doesn't know about.
continue
self.assertNotEqual(tslib._p_tz_cache_key(
tz_p), tslib._p_tz_cache_key(tz_d))
assert tslib._p_tz_cache_key(tz_p) != tslib._p_tz_cache_key(tz_d)


class TestTimeZones(tm.TestCase):
Expand Down

0 comments on commit d81d8ee

Please sign in to comment.