Skip to content

Commit 1f5ecc9

Browse files
gfyoungjreback
authored andcommitted
MAINT: Remove tm.TestCase from testing (#16225)
1 parent 4a748cc commit 1f5ecc9

File tree

208 files changed

+446
-491
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

208 files changed

+446
-491
lines changed

doc/source/contributing.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -617,11 +617,11 @@ the expected correct result::
617617
Transitioning to ``pytest``
618618
~~~~~~~~~~~~~~~~~~~~~~~~~~~
619619

620-
*pandas* existing test structure is *mostly* classed based, meaning that you will typically find tests wrapped in a class, inheriting from ``tm.TestCase``.
620+
*pandas* existing test structure is *mostly* classed based, meaning that you will typically find tests wrapped in a class.
621621

622622
.. code-block:: python
623623
624-
class TestReallyCoolFeature(tm.TestCase):
624+
class TestReallyCoolFeature(object):
625625
....
626626
627627
Going forward, we are moving to a more *functional* style using the `pytest <http://doc.pytest.org/en/latest/>`__ framework, which offers a richer testing

pandas/conftest.py

+7
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ def pytest_runtest_setup(item):
2525
pytest.skip("skipping due to --skip-network")
2626

2727

28+
# Configurations for all tests and all test modules
29+
30+
@pytest.fixture(autouse=True)
31+
def configure_tests():
32+
pandas.set_option('chained_assignment', 'raise')
33+
34+
2835
# For running doctests: make np and pd names available
2936

3037
@pytest.fixture(autouse=True)

pandas/tests/api/test_api.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def check(self, namespace, expected, ignored=None):
2323
tm.assert_almost_equal(result, expected)
2424

2525

26-
class TestPDApi(Base, tm.TestCase):
26+
class TestPDApi(Base):
2727

2828
# these are optionally imported based on testing
2929
# & need to be ignored
@@ -117,7 +117,7 @@ def test_api(self):
117117
self.ignored)
118118

119119

120-
class TestApi(Base, tm.TestCase):
120+
class TestApi(Base):
121121

122122
allowed = ['types']
123123

@@ -137,7 +137,7 @@ def test_testing(self):
137137
self.check(testing, self.funcs)
138138

139139

140-
class TestDatetoolsDeprecation(tm.TestCase):
140+
class TestDatetoolsDeprecation(object):
141141

142142
def test_deprecation_access_func(self):
143143
with tm.assert_produces_warning(FutureWarning,
@@ -150,7 +150,7 @@ def test_deprecation_access_obj(self):
150150
pd.datetools.monthEnd
151151

152152

153-
class TestTopLevelDeprecations(tm.TestCase):
153+
class TestTopLevelDeprecations(object):
154154

155155
# top-level API deprecations
156156
# GH 13790
@@ -191,35 +191,35 @@ def test_get_store(self):
191191
s.close()
192192

193193

194-
class TestJson(tm.TestCase):
194+
class TestJson(object):
195195

196196
def test_deprecation_access_func(self):
197197
with catch_warnings(record=True):
198198
pd.json.dumps([])
199199

200200

201-
class TestParser(tm.TestCase):
201+
class TestParser(object):
202202

203203
def test_deprecation_access_func(self):
204204
with catch_warnings(record=True):
205205
pd.parser.na_values
206206

207207

208-
class TestLib(tm.TestCase):
208+
class TestLib(object):
209209

210210
def test_deprecation_access_func(self):
211211
with catch_warnings(record=True):
212212
pd.lib.infer_dtype('foo')
213213

214214

215-
class TestTSLib(tm.TestCase):
215+
class TestTSLib(object):
216216

217217
def test_deprecation_access_func(self):
218218
with catch_warnings(record=True):
219219
pd.tslib.Timestamp('20160101')
220220

221221

222-
class TestTypes(tm.TestCase):
222+
class TestTypes(object):
223223

224224
def test_deprecation_access_func(self):
225225
with tm.assert_produces_warning(

pandas/tests/api/test_types.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from .test_api import Base
1414

1515

16-
class TestTypes(Base, tm.TestCase):
16+
class TestTypes(Base):
1717

1818
allowed = ['is_bool', 'is_bool_dtype',
1919
'is_categorical', 'is_categorical_dtype', 'is_complex',

pandas/tests/computation/test_eval.py

+4-9
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,10 @@ def _is_py3_complex_incompat(result, expected):
9595
_good_arith_ops = com.difference(_arith_ops_syms, _special_case_arith_ops_syms)
9696

9797

98-
class TestEvalNumexprPandas(tm.TestCase):
98+
class TestEvalNumexprPandas(object):
9999

100100
@classmethod
101101
def setup_class(cls):
102-
super(TestEvalNumexprPandas, cls).setup_class()
103102
tm.skip_if_no_ne()
104103
import numexpr as ne
105104
cls.ne = ne
@@ -108,7 +107,6 @@ def setup_class(cls):
108107

109108
@classmethod
110109
def teardown_class(cls):
111-
super(TestEvalNumexprPandas, cls).teardown_class()
112110
del cls.engine, cls.parser
113111
if hasattr(cls, 'ne'):
114112
del cls.ne
@@ -1067,19 +1065,17 @@ def test_performance_warning_for_poor_alignment(self, engine, parser):
10671065
# ------------------------------------
10681066
# Slightly more complex ops
10691067

1070-
class TestOperationsNumExprPandas(tm.TestCase):
1068+
class TestOperationsNumExprPandas(object):
10711069

10721070
@classmethod
10731071
def setup_class(cls):
1074-
super(TestOperationsNumExprPandas, cls).setup_class()
10751072
tm.skip_if_no_ne()
10761073
cls.engine = 'numexpr'
10771074
cls.parser = 'pandas'
10781075
cls.arith_ops = expr._arith_ops_syms + expr._cmp_ops_syms
10791076

10801077
@classmethod
10811078
def teardown_class(cls):
1082-
super(TestOperationsNumExprPandas, cls).teardown_class()
10831079
del cls.engine, cls.parser
10841080

10851081
def eval(self, *args, **kwargs):
@@ -1584,11 +1580,10 @@ def setup_class(cls):
15841580
cls.arith_ops = expr._arith_ops_syms + expr._cmp_ops_syms
15851581

15861582

1587-
class TestMathPythonPython(tm.TestCase):
1583+
class TestMathPythonPython(object):
15881584

15891585
@classmethod
15901586
def setup_class(cls):
1591-
super(TestMathPythonPython, cls).setup_class()
15921587
tm.skip_if_no_ne()
15931588
cls.engine = 'python'
15941589
cls.parser = 'pandas'
@@ -1873,7 +1868,7 @@ def test_negate_lt_eq_le(engine, parser):
18731868
tm.assert_frame_equal(result, expected)
18741869

18751870

1876-
class TestValidate(tm.TestCase):
1871+
class TestValidate(object):
18771872

18781873
def test_validate_bool_args(self):
18791874
invalid_values = [1, "True", [1, 2, 3], 5.0]

pandas/tests/dtypes/test_cast.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from pandas.util import testing as tm
2727

2828

29-
class TestMaybeDowncast(tm.TestCase):
29+
class TestMaybeDowncast(object):
3030

3131
def test_downcast_conv(self):
3232
# test downcasting
@@ -156,7 +156,7 @@ def test_infer_dtype_from_array(self, arr, expected):
156156
assert dtype == expected
157157

158158

159-
class TestMaybe(tm.TestCase):
159+
class TestMaybe(object):
160160

161161
def test_maybe_convert_string_to_array(self):
162162
result = maybe_convert_string_to_object('x')
@@ -214,7 +214,7 @@ def test_maybe_convert_scalar(self):
214214
assert result == Timedelta('1 day 1 min').value
215215

216216

217-
class TestConvert(tm.TestCase):
217+
class TestConvert(object):
218218

219219
def test_maybe_convert_objects_copy(self):
220220
values = np.array([1, 2])
@@ -233,7 +233,7 @@ def test_maybe_convert_objects_copy(self):
233233
assert values is not out
234234

235235

236-
class TestCommonTypes(tm.TestCase):
236+
class TestCommonTypes(object):
237237

238238
def test_numpy_dtypes(self):
239239
# (source_types, destination_type)

pandas/tests/dtypes/test_common.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import pandas.util.testing as tm
1313

1414

15-
class TestPandasDtype(tm.TestCase):
15+
class TestPandasDtype(object):
1616

1717
# Passing invalid dtype, both as a string or object, must raise TypeError
1818
# Per issue GH15520

pandas/tests/dtypes/test_concat.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22

33
import pandas as pd
44
import pandas.core.dtypes.concat as _concat
5-
import pandas.util.testing as tm
65

76

8-
class TestConcatCompat(tm.TestCase):
7+
class TestConcatCompat(object):
98

109
def check_concat(self, to_concat, exp):
1110
for klass in [pd.Index, pd.Series]:

pandas/tests/dtypes/test_generic.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
from warnings import catch_warnings
44
import numpy as np
55
import pandas as pd
6-
import pandas.util.testing as tm
76
from pandas.core.dtypes import generic as gt
87

98

10-
class TestABCClasses(tm.TestCase):
9+
class TestABCClasses(object):
1110
tuples = [[1, 2, 2], ['red', 'blue', 'red']]
1211
multi_index = pd.MultiIndex.from_arrays(tuples, names=('number', 'color'))
1312
datetime_index = pd.to_datetime(['2000/1/1', '2010/1/1'])

pandas/tests/dtypes/test_inference.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def test_is_recompilable():
226226
assert not inference.is_re_compilable(f)
227227

228228

229-
class TestInference(tm.TestCase):
229+
class TestInference(object):
230230

231231
def test_infer_dtype_bytes(self):
232232
compare = 'string' if PY2 else 'bytes'
@@ -405,7 +405,7 @@ def test_mixed_dtypes_remain_object_array(self):
405405
tm.assert_numpy_array_equal(result, array)
406406

407407

408-
class TestTypeInference(tm.TestCase):
408+
class TestTypeInference(object):
409409

410410
def test_length_zero(self):
411411
result = lib.infer_dtype(np.array([], dtype='i4'))
@@ -774,7 +774,7 @@ def test_categorical(self):
774774
assert result == 'categorical'
775775

776776

777-
class TestNumberScalar(tm.TestCase):
777+
class TestNumberScalar(object):
778778

779779
def test_is_number(self):
780780

@@ -917,7 +917,7 @@ def test_is_timedelta(self):
917917
assert not is_timedelta64_ns_dtype(tdi.astype('timedelta64[h]'))
918918

919919

920-
class Testisscalar(tm.TestCase):
920+
class Testisscalar(object):
921921

922922
def test_isscalar_builtin_scalars(self):
923923
assert is_scalar(None)

pandas/tests/dtypes/test_io.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from pandas.compat import long, u
88

99

10-
class TestParseSQL(tm.TestCase):
10+
class TestParseSQL(object):
1111

1212
def test_convert_sql_column_floats(self):
1313
arr = np.array([1.5, None, 3, 4.2], dtype=object)

pandas/tests/dtypes/test_missing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def test_notnull():
4545
assert (isinstance(isnull(s), Series))
4646

4747

48-
class TestIsNull(tm.TestCase):
48+
class TestIsNull(object):
4949

5050
def test_0d_array(self):
5151
assert isnull(np.array(np.nan))

pandas/tests/frame/test_alter_axes.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from pandas.tests.frame.common import TestData
2626

2727

28-
class TestDataFrameAlterAxes(tm.TestCase, TestData):
28+
class TestDataFrameAlterAxes(TestData):
2929

3030
def test_set_index(self):
3131
idx = Index(np.arange(len(self.mixed_frame)))
@@ -806,7 +806,7 @@ def test_set_index_preserve_categorical_dtype(self):
806806
tm.assert_frame_equal(result, df)
807807

808808

809-
class TestIntervalIndex(tm.TestCase):
809+
class TestIntervalIndex(object):
810810

811811
def test_setitem(self):
812812

pandas/tests/frame/test_analytics.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from pandas.tests.frame.common import TestData
2525

2626

27-
class TestDataFrameAnalytics(tm.TestCase, TestData):
27+
class TestDataFrameAnalytics(TestData):
2828

2929
# ---------------------------------------------------------------------=
3030
# Correlation and covariance

pandas/tests/frame/test_api.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def test_add_prefix_suffix(self):
6969
tm.assert_index_equal(with_suffix.columns, expected)
7070

7171

72-
class TestDataFrameMisc(tm.TestCase, SharedWithSparse, TestData):
72+
class TestDataFrameMisc(SharedWithSparse, TestData):
7373

7474
klass = DataFrame
7575

pandas/tests/frame/test_apply.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from pandas.tests.frame.common import TestData
2020

2121

22-
class TestDataFrameApply(tm.TestCase, TestData):
22+
class TestDataFrameApply(TestData):
2323

2424
def test_apply(self):
2525
with np.errstate(all='ignore'):
@@ -482,7 +482,7 @@ def zip_frames(*frames):
482482
return pd.concat(zipped, axis=1)
483483

484484

485-
class TestDataFrameAggregate(tm.TestCase, TestData):
485+
class TestDataFrameAggregate(TestData):
486486

487487
_multiprocess_can_split_ = True
488488

pandas/tests/frame/test_asof.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from .common import TestData
1010

1111

12-
class TestFrameAsof(TestData, tm.TestCase):
12+
class TestFrameAsof(TestData):
1313
def setup_method(self, method):
1414
self.N = N = 50
1515
self.rng = date_range('1/1/1990', periods=N, freq='53s')

pandas/tests/frame/test_axis_select_reindex.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from pandas.tests.frame.common import TestData
2323

2424

25-
class TestDataFrameSelectReindex(tm.TestCase, TestData):
25+
class TestDataFrameSelectReindex(TestData):
2626
# These are specific reindex-based tests; other indexing tests should go in
2727
# test_indexing
2828

pandas/tests/frame/test_block_internals.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
# structure
2929

3030

31-
class TestDataFrameBlockInternals(tm.TestCase, TestData):
31+
class TestDataFrameBlockInternals(TestData):
3232

3333
def test_cast_internals(self):
3434
casted = DataFrame(self.frame._data, dtype=int)

0 commit comments

Comments
 (0)