Skip to content

MAINT: Strip internals from TestCase class #16016

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pandas/tests/core/dtypes/test_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def f():
self.assertNotEqual(np.str_, self.dtype)

def test_pickle(self):
result = self.round_trip_pickle(self.dtype)
result = tm.round_trip_pickle(self.dtype)
self.assertEqual(result, self.dtype)


Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/core/sparse/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ def _check_inplace_op(op):

def test_pickle(self):
def _check_roundtrip(obj):
unpickled = self.round_trip_pickle(obj)
unpickled = tm.round_trip_pickle(obj)
tm.assert_sp_array_equal(unpickled, obj)

_check_roundtrip(self.arr)
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/core/sparse/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def test_array_interface(self):
def test_pickle(self):

def _test_roundtrip(frame, orig):
result = self.round_trip_pickle(frame)
result = tm.round_trip_pickle(frame)
tm.assert_sp_frame_equal(frame, result)
tm.assert_frame_equal(result.to_dense(), orig, check_dtype=False)

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/core/sparse/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ def test_to_frame(self):

def test_pickle(self):
def _test_roundtrip(series):
unpickled = self.round_trip_pickle(series)
unpickled = tm.round_trip_pickle(series)
tm.assert_sp_series_equal(series, unpickled)
tm.assert_series_equal(series.to_dense(), unpickled.to_dense())

Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/frame/test_block_internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,18 +350,18 @@ def test_copy(self):
self.assertIsNot(copy._data, self.mixed_frame._data)

def test_pickle(self):
unpickled = self.round_trip_pickle(self.mixed_frame)
unpickled = tm.round_trip_pickle(self.mixed_frame)
assert_frame_equal(self.mixed_frame, unpickled)

# buglet
self.mixed_frame._data.ndim

# empty
unpickled = self.round_trip_pickle(self.empty)
unpickled = tm.round_trip_pickle(self.empty)
repr(unpickled)

# tz frame
unpickled = self.round_trip_pickle(self.tzframe)
unpickled = tm.round_trip_pickle(self.tzframe)
assert_frame_equal(self.tzframe, unpickled)

def test_consolidate_datetime64(self):
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/frame/test_repr_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def test_repr_unsortable(self):
fmt.set_option('display.max_rows', 1000, 'display.max_columns', 1000)
repr(self.frame)

self.reset_display_options()
tm.reset_display_options()

warnings.filters = warn_filters

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/frame/test_subclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def test_dataframe_metadata(self):
self.assertEqual(df.iloc[0:1, :].testattr, 'XXX')

# GH10553
unpickled = self.round_trip_pickle(df)
unpickled = tm.round_trip_pickle(df)
tm.assert_frame_equal(df, unpickled)
self.assertEqual(df._metadata, unpickled._metadata)
self.assertEqual(df.testattr, unpickled.testattr)
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def setup_indices(self):
setattr(self, name, idx)

def verify_pickle(self, index):
unpickled = self.round_trip_pickle(index)
unpickled = tm.round_trip_pickle(index)
self.assertTrue(index.equals(unpickled))

def test_pickle_compat_construction(self):
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/datetimes/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def test_roundtrip_pickle_with_tz(self):
# GH 8367
# round-trip of timezone
index = date_range('20130101', periods=3, tz='US/Eastern', name='foo')
unpickled = self.round_trip_pickle(index)
unpickled = tm.round_trip_pickle(index)
self.assert_index_equal(index, unpickled)

def test_reindex_preserves_tz_if_target_is_empty_list_or_array(self):
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/indexes/datetimes/test_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -1121,7 +1121,7 @@ def test_comparison(self):
self.assertFalse(comp[9])

def test_pickle_unpickle(self):
unpickled = self.round_trip_pickle(self.rng)
unpickled = tm.round_trip_pickle(self.rng)
self.assertIsNotNone(unpickled.offset)

def test_copy(self):
Expand Down Expand Up @@ -1272,7 +1272,7 @@ def test_shift(self):
self.assertEqual(shifted[0], rng[0] + CDay())

def test_pickle_unpickle(self):
unpickled = self.round_trip_pickle(self.rng)
unpickled = tm.round_trip_pickle(self.rng)
self.assertIsNotNone(unpickled.offset)

def test_summary(self):
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/indexes/period/test_period.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def test_pickle_compat_construction(self):
def test_pickle_round_trip(self):
for freq in ['D', 'M', 'Y']:
idx = PeriodIndex(['2016-05-16', 'NaT', NaT, np.NaN], freq='D')
result = self.round_trip_pickle(idx)
result = tm.round_trip_pickle(idx)
tm.assert_index_equal(result, idx)

def test_get_loc(self):
Expand Down Expand Up @@ -761,7 +761,7 @@ def test_append_concat(self):
def test_pickle_freq(self):
# GH2891
prng = period_range('1/1/2011', '1/1/2012', freq='M')
new_prng = self.round_trip_pickle(prng)
new_prng = tm.round_trip_pickle(prng)
self.assertEqual(new_prng.freq, offsets.MonthEnd())
self.assertEqual(new_prng.freqstr, 'M')

Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/indexes/test_multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,7 @@ def test_roundtrip_pickle_with_tz(self):
[[1, 2], ['a', 'b'], date_range('20130101', periods=3,
tz='US/Eastern')
], names=['one', 'two', 'three'])
unpickled = self.round_trip_pickle(index)
unpickled = tm.round_trip_pickle(index)
self.assertTrue(index.equal_levels(unpickled))

def test_from_tuples_index_values(self):
Expand Down Expand Up @@ -1392,7 +1392,7 @@ def test_format_sparse_config(self):
result = self.index.format()
self.assertEqual(result[1], 'foo two')

self.reset_display_options()
tm.reset_display_options()

warnings.filters = warn_filters

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/timedeltas/test_timedelta.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ def test_pass_TimedeltaIndex_to_index(self):
def test_pickle(self):

rng = timedelta_range('1 days', periods=10)
rng_p = self.round_trip_pickle(rng)
rng_p = tm.round_trip_pickle(rng)
tm.assert_index_equal(rng, rng_p)

def test_hash_error(self):
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/io/formats/test_eng_formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_eng_float_formatter(self):
'3 1E+06')
self.assertEqual(result, expected)

self.reset_display_options()
tm.reset_display_options()

def compare(self, formatter, input, output):
formatted_input = formatter(input)
Expand Down Expand Up @@ -185,7 +185,7 @@ def test_nan(self):
fmt.set_eng_float_format(accuracy=1)
result = pt.to_string()
self.assertTrue('NaN' in result)
self.reset_display_options()
tm.reset_display_options()

def test_inf(self):
# Issue #11981
Expand Down
16 changes: 8 additions & 8 deletions pandas/tests/io/formats/test_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def test_eng_float_formatter(self):

fmt.set_eng_float_format(accuracy=0)
repr(self.frame)
self.reset_display_options()
tm.reset_display_options()

def test_show_null_counts(self):

Expand Down Expand Up @@ -1197,7 +1197,7 @@ def test_to_string_line_width_no_index(self):
self.assertEqual(df_s, expected)

def test_to_string_float_formatting(self):
self.reset_display_options()
tm.reset_display_options()
fmt.set_option('display.precision', 5, 'display.column_space', 12,
'display.notebook_repr_html', False)

Expand Down Expand Up @@ -1226,7 +1226,7 @@ def test_to_string_float_formatting(self):
expected = (' x\n' '0 3234.000\n' '1 0.253')
self.assertEqual(df_s, expected)

self.reset_display_options()
tm.reset_display_options()
self.assertEqual(get_option("display.precision"), 6)

df = DataFrame({'x': [1e9, 0.2512]})
Expand Down Expand Up @@ -1310,14 +1310,14 @@ def test_to_string_index_formatter(self):
self.assertEqual(rs, xp)

def test_to_string_left_justify_cols(self):
self.reset_display_options()
tm.reset_display_options()
df = DataFrame({'x': [3234, 0.253]})
df_s = df.to_string(justify='left')
expected = (' x \n' '0 3234.000\n' '1 0.253')
self.assertEqual(df_s, expected)

def test_to_string_format_na(self):
self.reset_display_options()
tm.reset_display_options()
df = DataFrame({'A': [np.nan, -1, -2.1234, 3, 4],
'B': [np.nan, 'foo', 'foooo', 'fooooo', 'bar']})
result = df.to_string()
Expand Down Expand Up @@ -1380,15 +1380,15 @@ def test_repr_html(self):
fmt.set_option('display.notebook_repr_html', False)
self.frame._repr_html_()

self.reset_display_options()
tm.reset_display_options()

df = DataFrame([[1, 2], [3, 4]])
fmt.set_option('display.show_dimensions', True)
self.assertTrue('2 rows' in df._repr_html_())
fmt.set_option('display.show_dimensions', False)
self.assertFalse('2 rows' in df._repr_html_())

self.reset_display_options()
tm.reset_display_options()

def test_repr_html_wide(self):
max_cols = get_option('display.max_columns')
Expand Down Expand Up @@ -1552,7 +1552,7 @@ def get_ipython():
repstr = self.frame._repr_html_()
self.assertIn('class', repstr) # info fallback

self.reset_display_options()
tm.reset_display_options()

def test_pprint_pathological_object(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/scalar/test_period.py
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ def test_multiples(self):
def test_round_trip(self):

p = Period('2000Q1')
new_p = self.round_trip_pickle(p)
new_p = tm.round_trip_pickle(p)
self.assertEqual(new_p, p)


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 @@ -559,7 +559,7 @@ def test_overflow(self):
def test_pickle(self):

v = Timedelta('1 days 10:11:12.0123456')
v_p = self.round_trip_pickle(v)
v_p = tm.round_trip_pickle(v)
self.assertEqual(v, v_p)

def test_timedelta_hash_equality(self):
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/series/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def test_timeseries_periodindex(self):
from pandas import period_range
prng = period_range('1/1/2011', '1/1/2012', freq='M')
ts = Series(np.random.randn(len(prng)), prng)
new_ts = self.round_trip_pickle(ts)
new_ts = tm.round_trip_pickle(ts)
self.assertEqual(new_ts.index.freq, 'M')

def test_pickle_preserve_name(self):
Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/series/test_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -827,19 +827,19 @@ def test_asfreq_resample_set_correct_freq(self):
def test_pickle(self):

# GH4606
p = self.round_trip_pickle(NaT)
p = tm.round_trip_pickle(NaT)
self.assertTrue(p is NaT)

idx = pd.to_datetime(['2013-01-01', NaT, '2014-01-06'])
idx_p = self.round_trip_pickle(idx)
idx_p = tm.round_trip_pickle(idx)
self.assertTrue(idx_p[0] == idx[0])
self.assertTrue(idx_p[1] is NaT)
self.assertTrue(idx_p[2] == idx[2])

# GH11002
# don't infer freq
idx = date_range('1750-1-1', '2050-1-1', freq='7D')
idx_p = self.round_trip_pickle(idx)
idx_p = tm.round_trip_pickle(idx)
tm.assert_index_equal(idx, idx_p)

def test_setops_preserve_freq(self):
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/test_multilevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def _check_op(opname):

def test_pickle(self):
def _test_roundtrip(frame):
unpickled = self.round_trip_pickle(frame)
unpickled = tm.round_trip_pickle(frame)
tm.assert_frame_equal(frame, unpickled)

_test_roundtrip(self.frame)
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 @@ -43,7 +43,7 @@ class PanelTests(object):

def test_pickle(self):
with catch_warnings(record=True):
unpickled = self.round_trip_pickle(self.panel)
unpickled = tm.round_trip_pickle(self.panel)
assert_frame_equal(unpickled['ItemA'], self.panel['ItemA'])

def test_rank(self):
Expand Down
20 changes: 0 additions & 20 deletions pandas/tests/test_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -746,26 +746,6 @@ def test_RNGContext(self):
self.assertEqual(np.random.randn(), expected0)


class TestDeprecatedTests(tm.TestCase):

def test_warning(self):

with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
self.assertEquals(1, 1)

with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
self.assertNotEquals(1, 2)

with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
self.assert_(True)

with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
self.assertAlmostEquals(1.0, 1.0000000001)

with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
self.assertNotAlmostEquals(1, 2)


class TestLocale(tm.TestCase):

def test_locale(self):
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/tseries/test_offsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1906,7 +1906,7 @@ def test_calendar(self):

def test_roundtrip_pickle(self):
def _check_roundtrip(obj):
unpickled = self.round_trip_pickle(obj)
unpickled = tm.round_trip_pickle(obj)
self.assertEqual(unpickled, obj)

_check_roundtrip(self.offset)
Expand Down Expand Up @@ -1967,7 +1967,7 @@ def test_offsets_compare_equal(self):

def test_roundtrip_pickle(self):
def _check_roundtrip(obj):
unpickled = self.round_trip_pickle(obj)
unpickled = tm.round_trip_pickle(obj)
self.assertEqual(unpickled, obj)

_check_roundtrip(self._object())
Expand Down
2 changes: 1 addition & 1 deletion pandas/util/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def deprecate_kwarg(old_arg_name, new_arg_name, mapping=None, stacklevel=2):
old_arg_name : str
Name of argument in function to deprecate
new_arg_name : str
Name of prefered argument in function
Name of preferred argument in function
mapping : dict or callable
If mapping is present, use it to translate old arguments to
new arguments. A callable must do its own value checking;
Expand Down
Loading