From 549c3d796276ce2cac4347fab10db9dfe2fb4d94 Mon Sep 17 00:00:00 2001 From: gfyoung Date: Sat, 29 Apr 2017 16:37:53 -0400 Subject: [PATCH] MAINT: Remove self.assertNotEqual from testing --- pandas/tests/frame/test_api.py | 2 +- pandas/tests/frame/test_indexing.py | 2 +- pandas/tests/frame/test_sorting.py | 2 +- pandas/tests/groupby/test_groupby.py | 2 +- pandas/tests/indexes/test_base.py | 2 +- pandas/tests/indexes/test_numeric.py | 2 +- pandas/tests/io/formats/test_format.py | 10 +++++----- pandas/tests/io/formats/test_style.py | 4 ++-- pandas/tests/io/test_common.py | 4 ++-- pandas/tests/scalar/test_period.py | 4 ++-- pandas/tests/scalar/test_timedelta.py | 2 +- pandas/tests/scalar/test_timestamp.py | 10 +++++----- pandas/tests/series/test_missing.py | 6 +++--- pandas/tests/test_expressions.py | 4 ++-- pandas/tests/test_panel.py | 2 +- pandas/tests/test_panel4d.py | 2 +- pandas/tests/tseries/test_offsets.py | 19 +++++++++---------- pandas/tests/tseries/test_timezones.py | 3 +-- 18 files changed, 40 insertions(+), 42 deletions(-) diff --git a/pandas/tests/frame/test_api.py b/pandas/tests/frame/test_api.py index d2a1e32f015b2..208c7b5ace50e 100644 --- a/pandas/tests/frame/test_api.py +++ b/pandas/tests/frame/test_api.py @@ -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 diff --git a/pandas/tests/frame/test_indexing.py b/pandas/tests/frame/test_indexing.py index cd1529d04c991..75d4263cbe68f 100644 --- a/pandas/tests/frame/test_indexing.py +++ b/pandas/tests/frame/test_indexing.py @@ -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))}) diff --git a/pandas/tests/frame/test_sorting.py b/pandas/tests/frame/test_sorting.py index bdb5fd0e8354c..457ea32ec56f7 100644 --- a/pandas/tests/frame/test_sorting.py +++ b/pandas/tests/frame/test_sorting.py @@ -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) diff --git a/pandas/tests/groupby/test_groupby.py b/pandas/tests/groupby/test_groupby.py index 09643e918af31..8d86d40c379bf 100644 --- a/pandas/tests/groupby/test_groupby.py +++ b/pandas/tests/groupby/test_groupby.py @@ -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' diff --git a/pandas/tests/indexes/test_base.py b/pandas/tests/indexes/test_base.py index 23c72e511d2b3..10958681af450 100644 --- a/pandas/tests/indexes/test_base.py +++ b/pandas/tests/indexes/test_base.py @@ -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.) diff --git a/pandas/tests/indexes/test_numeric.py b/pandas/tests/indexes/test_numeric.py index 19bca875e650d..428c261df5654 100644 --- a/pandas/tests/indexes/test_numeric.py +++ b/pandas/tests/indexes/test_numeric.py @@ -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]) diff --git a/pandas/tests/io/formats/test_format.py b/pandas/tests/io/formats/test_format.py index dee645e9d70ec..ac00e441047dd 100644 --- a/pandas/tests/io/formats/test_format.py +++ b/pandas/tests/io/formats/test_format.py @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) diff --git a/pandas/tests/io/formats/test_style.py b/pandas/tests/io/formats/test_style.py index 371cc2b61634a..f421c0f8e6d69 100644 --- a/pandas/tests/io/formats/test_style.py +++ b/pandas/tests/io/formats/test_style.py @@ -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() diff --git a/pandas/tests/io/test_common.py b/pandas/tests/io/test_common.py index 804d76c3c9eca..c427fab4103e0 100644 --- a/pandas/tests/io/test_common.py +++ b/pandas/tests/io/test_common.py @@ -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 @@ -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 diff --git a/pandas/tests/scalar/test_period.py b/pandas/tests/scalar/test_period.py index 00a1fa1b507b6..2e60cfdb7a4f2 100644 --- a/pandas/tests/scalar/test_period.py +++ b/pandas/tests/scalar/test_period.py @@ -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 diff --git a/pandas/tests/scalar/test_timedelta.py b/pandas/tests/scalar/test_timedelta.py index faddbcc84109f..5659bc26fc1cc 100644 --- a/pandas/tests/scalar/test_timedelta.py +++ b/pandas/tests/scalar/test_timedelta.py @@ -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) diff --git a/pandas/tests/scalar/test_timestamp.py b/pandas/tests/scalar/test_timestamp.py index 8a28a9a4bedd0..04b33bbc6c3bf 100644 --- a/pandas/tests/scalar/test_timestamp.py +++ b/pandas/tests/scalar/test_timestamp.py @@ -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 @@ -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) diff --git a/pandas/tests/series/test_missing.py b/pandas/tests/series/test_missing.py index 9937f6a34172e..0eaab2e588cc2 100644 --- a/pandas/tests/series/test_missing.py +++ b/pandas/tests/series/test_missing.py @@ -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() @@ -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) diff --git a/pandas/tests/test_expressions.py b/pandas/tests/test_expressions.py index ae505a66ad75a..8ef29097b66e8 100644 --- a/pandas/tests/test_expressions.py +++ b/pandas/tests/test_expressions.py @@ -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) @@ -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) diff --git a/pandas/tests/test_panel.py b/pandas/tests/test_panel.py index a692f6b26c61e..b9cceab4d65f4 100644 --- a/pandas/tests/test_panel.py +++ b/pandas/tests/test_panel.py @@ -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): diff --git a/pandas/tests/test_panel4d.py b/pandas/tests/test_panel4d.py index f2a1414957d44..041e36848e1d8 100644 --- a/pandas/tests/test_panel4d.py +++ b/pandas/tests/test_panel4d.py @@ -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): diff --git a/pandas/tests/tseries/test_offsets.py b/pandas/tests/tseries/test_offsets.py index ce4208a8cea69..79190aa98f8d9 100644 --- a/pandas/tests/tseries/test_offsets.py +++ b/pandas/tests/tseries/test_offsets.py @@ -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): @@ -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]: @@ -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)) @@ -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)) @@ -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: diff --git a/pandas/tests/tseries/test_timezones.py b/pandas/tests/tseries/test_timezones.py index 8b6774885c8b7..0c8aaf77aec12 100644 --- a/pandas/tests/tseries/test_timezones.py +++ b/pandas/tests/tseries/test_timezones.py @@ -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):