Skip to content

Commit 23bf4da

Browse files
authored
fix nightly tests to work with 2.1 dev code (#742)
1 parent 1ef1478 commit 23bf4da

9 files changed

+856
-533
lines changed

tests/test_api_types.py

Lines changed: 54 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88

99
from pandas._typing import DtypeObj
1010

11-
from tests import check
11+
from tests import (
12+
check,
13+
pytest_warns_bounded,
14+
)
1215

1316
nparr = np.array([1, 2, 3])
1417
arr = pd.Series([1, 2, 3])
@@ -52,12 +55,15 @@ def test_is_bool_dtype() -> None:
5255

5356

5457
def test_is_categorical_dtype() -> None:
55-
check(assert_type(api.is_categorical_dtype(arr), bool), bool)
56-
check(assert_type(api.is_categorical_dtype(nparr), bool), bool)
57-
check(assert_type(api.is_categorical_dtype(dtylike), bool), bool)
58-
check(assert_type(api.is_categorical_dtype(dframe), bool), bool)
59-
check(assert_type(api.is_categorical_dtype(ind), bool), bool)
60-
check(assert_type(api.is_categorical_dtype(ExtensionDtype), bool), bool)
58+
with pytest_warns_bounded(
59+
FutureWarning, "is_categorical_dtype is deprecated", lower="2.0.99"
60+
):
61+
check(assert_type(api.is_categorical_dtype(arr), bool), bool)
62+
check(assert_type(api.is_categorical_dtype(nparr), bool), bool)
63+
check(assert_type(api.is_categorical_dtype(dtylike), bool), bool)
64+
check(assert_type(api.is_categorical_dtype(dframe), bool), bool)
65+
check(assert_type(api.is_categorical_dtype(ind), bool), bool)
66+
check(assert_type(api.is_categorical_dtype(ExtensionDtype), bool), bool)
6167

6268

6369
def test_is_complex() -> None:
@@ -121,12 +127,15 @@ def test_is_datetime64_ns_dtype() -> None:
121127

122128

123129
def test_is_datetime64tz_dtype() -> None:
124-
check(assert_type(api.is_datetime64tz_dtype(arr), bool), bool)
125-
check(assert_type(api.is_datetime64tz_dtype(nparr), bool), bool)
126-
check(assert_type(api.is_datetime64tz_dtype(dtylike), bool), bool)
127-
check(assert_type(api.is_datetime64tz_dtype(dframe), bool), bool)
128-
check(assert_type(api.is_datetime64tz_dtype(ind), bool), bool)
129-
check(assert_type(api.is_datetime64tz_dtype(ExtensionDtype), bool), bool)
130+
with pytest_warns_bounded(
131+
FutureWarning, "is_datetime64tz_dtype is deprecated", lower="2.0.99"
132+
):
133+
check(assert_type(api.is_datetime64tz_dtype(arr), bool), bool)
134+
check(assert_type(api.is_datetime64tz_dtype(nparr), bool), bool)
135+
check(assert_type(api.is_datetime64tz_dtype(dtylike), bool), bool)
136+
check(assert_type(api.is_datetime64tz_dtype(dframe), bool), bool)
137+
check(assert_type(api.is_datetime64tz_dtype(ind), bool), bool)
138+
check(assert_type(api.is_datetime64tz_dtype(ExtensionDtype), bool), bool)
130139

131140

132141
def test_is_dict_like() -> None:
@@ -203,12 +212,15 @@ def test_is_hashable() -> None:
203212

204213

205214
def test_is_int64_dtype() -> None:
206-
check(assert_type(api.is_int64_dtype(arr), bool), bool)
207-
check(assert_type(api.is_int64_dtype(nparr), bool), bool)
208-
check(assert_type(api.is_int64_dtype(dtylike), bool), bool)
209-
check(assert_type(api.is_int64_dtype(dframe), bool), bool)
210-
check(assert_type(api.is_int64_dtype(ind), bool), bool)
211-
# check(assert_type(api.is_int64_dtype(ExtensionDtype), bool), bool) pandas GH 50923
215+
with pytest_warns_bounded(
216+
FutureWarning, "is_int64_dtype is deprecated", lower="2.0.99"
217+
):
218+
check(assert_type(api.is_int64_dtype(arr), bool), bool)
219+
check(assert_type(api.is_int64_dtype(nparr), bool), bool)
220+
check(assert_type(api.is_int64_dtype(dtylike), bool), bool)
221+
check(assert_type(api.is_int64_dtype(dframe), bool), bool)
222+
check(assert_type(api.is_int64_dtype(ind), bool), bool)
223+
# check(assert_type(api.is_int64_dtype(ExtensionDtype), bool), bool) pandas GH 50923
212224

213225

214226
def test_is_integer() -> None:
@@ -248,13 +260,16 @@ def test_is_interval() -> None:
248260

249261

250262
def test_is_interval_dtype() -> None:
251-
check(assert_type(api.is_interval_dtype(obj), bool), bool)
252-
check(assert_type(api.is_interval_dtype(nparr), bool), bool)
253-
check(assert_type(api.is_interval_dtype(dtylike), bool), bool)
254-
check(assert_type(api.is_interval_dtype(arr), bool), bool)
255-
check(assert_type(api.is_interval_dtype(dframe), bool), bool)
256-
check(assert_type(api.is_interval_dtype(ind), bool), bool)
257-
check(assert_type(api.is_interval_dtype(ExtensionDtype), bool), bool)
263+
with pytest_warns_bounded(
264+
FutureWarning, "is_interval_dtype is deprecated", lower="2.0.99"
265+
):
266+
check(assert_type(api.is_interval_dtype(obj), bool), bool)
267+
check(assert_type(api.is_interval_dtype(nparr), bool), bool)
268+
check(assert_type(api.is_interval_dtype(dtylike), bool), bool)
269+
check(assert_type(api.is_interval_dtype(arr), bool), bool)
270+
check(assert_type(api.is_interval_dtype(dframe), bool), bool)
271+
check(assert_type(api.is_interval_dtype(ind), bool), bool)
272+
check(assert_type(api.is_interval_dtype(ExtensionDtype), bool), bool)
258273

259274

260275
def test_is_iterator() -> None:
@@ -327,12 +342,15 @@ def test_is_object_dtype() -> None:
327342

328343

329344
def test_is_period_dtype() -> None:
330-
check(assert_type(api.is_period_dtype(arr), bool), bool)
331-
check(assert_type(api.is_period_dtype(nparr), bool), bool)
332-
check(assert_type(api.is_period_dtype(dtylike), bool), bool)
333-
check(assert_type(api.is_period_dtype(dframe), bool), bool)
334-
check(assert_type(api.is_period_dtype(ind), bool), bool)
335-
check(assert_type(api.is_period_dtype(ExtensionDtype), bool), bool)
345+
with pytest_warns_bounded(
346+
FutureWarning, "is_period_dtype is deprecated", lower="2.0.99"
347+
):
348+
check(assert_type(api.is_period_dtype(arr), bool), bool)
349+
check(assert_type(api.is_period_dtype(nparr), bool), bool)
350+
check(assert_type(api.is_period_dtype(dtylike), bool), bool)
351+
check(assert_type(api.is_period_dtype(dframe), bool), bool)
352+
check(assert_type(api.is_period_dtype(ind), bool), bool)
353+
check(assert_type(api.is_period_dtype(ExtensionDtype), bool), bool)
336354

337355

338356
def test_is_re() -> None:
@@ -378,9 +396,10 @@ def test_is_signed_integer_dtype() -> None:
378396

379397

380398
def test_is_sparse() -> None:
381-
check(assert_type(api.is_sparse(arr), bool), bool)
382-
check(assert_type(api.is_sparse(nparr), bool), bool)
383-
check(assert_type(api.is_sparse(dframe), bool), bool)
399+
with pytest_warns_bounded(FutureWarning, "is_sparse is deprecated", lower="2.0.99"):
400+
check(assert_type(api.is_sparse(arr), bool), bool)
401+
check(assert_type(api.is_sparse(nparr), bool), bool)
402+
check(assert_type(api.is_sparse(dframe), bool), bool)
384403

385404

386405
def test_is_string_dtype() -> None:

0 commit comments

Comments
 (0)