Skip to content

Commit ef0a96d

Browse files
authored
Remove stale python filterwarnings and skipped tests (rapidsai#22706)
* Removes and improves some `filterwarnings` used in unit tests * Removes `test_magics_cpu` as it's been perpetually skipped without resolution Authors: - Matthew Roeschke (https://github.com/mroeschke) Approvers: - Lawrence Mitchell (https://github.com/wence-) - James Lamb (https://github.com/jameslamb) URL: rapidsai#22706
1 parent be99a3d commit ef0a96d

11 files changed

Lines changed: 54 additions & 100 deletions

File tree

python/cudf/cudf/tests/input_output/test_feather.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ def pdf(request):
3333

3434

3535
@pytest.mark.filterwarnings("ignore:Using CPU")
36-
@pytest.mark.filterwarnings("ignore:Strings are not yet supported")
3736
@pytest.mark.parametrize(
3837
"columns",
3938
[["col_int8"], ["col_category"], ["col_int32", "col_float32"], None],

python/cudf/cudf/tests/input_output/test_hdf5.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: Copyright (c) 2018-2025, NVIDIA CORPORATION.
1+
# SPDX-FileCopyrightText: Copyright (c) 2018-2026, NVIDIA CORPORATION.
22
# SPDX-License-Identifier: Apache-2.0
33

44
import os
@@ -69,7 +69,6 @@ def hdf_files(request, tmp_path, pdf):
6969

7070

7171
@pytest.mark.filterwarnings("ignore:Using CPU")
72-
@pytest.mark.filterwarnings("ignore:Strings are not yet supported")
7372
@pytest.mark.parametrize(
7473
"columns",
7574
[["col_int8"], ["col_category"], ["col_int32", "col_float32"], None],

python/cudf/cudf/tests/input_output/test_json.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ def gdf_writer_types(request):
8282
return test_pdf
8383

8484

85-
@pytest.mark.filterwarnings("ignore:Strings are not yet supported")
8685
@pytest.mark.filterwarnings("ignore:Using CPU")
8786
@pytest.mark.parametrize("index", [True, False])
8887
# tests limited to compressions formats supported by pandas and cudf: bz2, gzip, zip, zstd

python/cudf/cudf/tests/series/test_binops.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3039,7 +3039,6 @@ def test_binop_index_series(arithmetic_op):
30393039
assert_eq(expected, actual)
30403040

30413041

3042-
@pytest.mark.filterwarnings("ignore::DeprecationWarning")
30433042
@pytest.mark.parametrize("name1", [None, "name1"])
30443043
@pytest.mark.parametrize("name2", [None, "name2"])
30453044
def test_binop_index_dt_td_series_with_names(name1, name2):

python/cudf/cudf/tests/test_doctests.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
import cudf
1313

14-
pytestmark = pytest.mark.filterwarnings("ignore::FutureWarning")
1514
_SKIP_DOCTESTS = frozenset(
1615
{
1716
"register_dataframe_accessor",
@@ -88,6 +87,22 @@ def _find_doctests_in_obj(obj, finder=None, criteria=None):
8887
yield docstring
8988

9089

90+
marks_for_doctests = {
91+
"register_dataframe_accessor": pytest.mark.filterwarnings(
92+
"ignore:Attribute .* will be overridden:UserWarning"
93+
),
94+
"register_index_accessor": pytest.mark.filterwarnings(
95+
"ignore:Attribute .* will be overridden:UserWarning"
96+
),
97+
"register_series_accessor": pytest.mark.filterwarnings(
98+
"ignore:Attribute .* will be overridden:UserWarning"
99+
),
100+
"StringMethods.edit_distance_matrix": pytest.mark.filterwarnings(
101+
"ignore:edit_distance_matrix:FutureWarning"
102+
),
103+
}
104+
105+
91106
def _collect_doctests():
92107
"""Eagerly collect all unique doctests into a list.
93108
@@ -98,7 +113,11 @@ def _collect_doctests():
98113
results = []
99114
for mod in tests:
100115
for docstring in _find_doctests_in_obj(mod):
101-
results.append(docstring)
116+
if (mark := marks_for_doctests.get(docstring.name)) is not None:
117+
doc = pytest.param(docstring, marks=mark)
118+
else:
119+
doc = docstring
120+
results.append(doc)
102121
return results
103122

104123

@@ -122,8 +141,6 @@ def printoptions(cls):
122141
ids=lambda docstring: docstring.name,
123142
)
124143
def test_docstring(self, docstring, monkeypatch, tmp_path):
125-
if docstring.name in _SKIP_DOCTESTS:
126-
pytest.skip(f"{docstring.name} doctest is not runnable")
127144
# We ignore differences in whitespace in the doctest output, and enable
128145
# the use of an ellipsis "..." to match any string in the doctest
129146
# output. An ellipsis is useful for, e.g., memory addresses or

python/cudf/cudf/tests/test_flags.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,17 +172,16 @@ def test_set_flags_no_change_when_none(frame_or_series):
172172
_assert_flags_eq(cu_new, pd_new)
173173

174174

175+
@pytest.mark.filterwarnings(
176+
"ignore:The copy keyword is deprecated:pandas.errors.Pandas4Warning"
177+
)
175178
def test_set_flags_copy_true_makes_deep_copy():
176179
# Match pandas' observable behaviour: mutating the copy does not
177180
# alter the original. ``copy=True`` is deprecated in pandas 3; we
178181
# still accept it for API parity.
179-
import warnings
180-
181182
pdf = pd.DataFrame({"a": [1, 2, 3]})
182183
gdf = cudf.DataFrame({"a": [1, 2, 3]})
183-
with warnings.catch_warnings():
184-
warnings.simplefilter("ignore")
185-
p_new = pdf.set_flags(copy=True, allows_duplicate_labels=False)
184+
p_new = pdf.set_flags(copy=True, allows_duplicate_labels=False)
186185
g_new = gdf.set_flags(copy=True, allows_duplicate_labels=False)
187186
p_new.loc[0, "a"] = 99
188187
g_new.loc[0, "a"] = 99

python/cudf/cudf_pandas_tests/_magics_cpu_test.py

Lines changed: 0 additions & 29 deletions
This file was deleted.

python/cudf/cudf_pandas_tests/test_magics.py

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
# SPDX-FileCopyrightText: Copyright (c) 2023-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
1+
# SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4-
import os
54
import pathlib
65
import subprocess
76
import sys
@@ -31,19 +30,3 @@ def test_magics_gpu():
3130
[sys.executable, LOCATION / "_magics_gpu_test.py"], capture_output=True
3231
)
3332
assert sp_completed.stderr.decode() == ""
34-
35-
36-
@pytest.mark.skip(
37-
"This test was viable when cudf.pandas was separate from cudf, but now "
38-
"that it is a subpackage we always require a GPU to be present and cannot "
39-
"run this test."
40-
)
41-
def test_magics_cpu():
42-
env = os.environ.copy()
43-
env["CUDA_VISIBLE_DEVICES"] = ""
44-
sp_completed = subprocess.run(
45-
[sys.executable, LOCATION / "_magics_cpu_test.py"],
46-
capture_output=True,
47-
env=env,
48-
)
49-
assert sp_completed.stderr.decode() == ""

python/cudf/pyproject.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@ filterwarnings = [
100100
"error",
101101
"ignore:::.*xdist.*",
102102
"ignore:::.*pytest.*",
103-
# some third-party dependencies (e.g. 'boto3') still using datetime.datetime.utcnow()
104-
"ignore:.*datetime.*utcnow.*scheduled for removal.*:DeprecationWarning:botocore",
105103
# Deprecation warning from Pyarrow Table.to_pandas() with pandas-2.2+
106104
"ignore:Passing a BlockManager to DataFrame is deprecated:DeprecationWarning",
107105
# PerformanceWarning from cupy warming up the JIT cache
@@ -114,7 +112,6 @@ filterwarnings = [
114112
markers = [
115113
"spilling: mark benchmark a good candidate to run with `CUDF_SPILL=ON`",
116114
"serial: Mark a test as not being parallel-safe.",
117-
"no_copy_on_write: A test that is not valid when copy-on-write is enabled.",
118115
]
119116
xfail_strict = true
120117

python/dask_cudf/dask_cudf/tests/test_distributed.py

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -82,23 +82,22 @@ def test_merge():
8282
@pytest.mark.skipif(
8383
not at_least_n_gpus(2), reason="Machine does not have two GPUs"
8484
)
85+
@pytest.mark.filterwarnings("ignore:Port")
8586
def test_ucx_seriesgroupby():
8687
pytest.importorskip("distributed_ucxx")
8788

88-
with warnings.catch_warnings():
89-
warnings.filterwarnings("ignore", category=Warning, message="Port")
90-
with (
91-
dask_cuda.LocalCUDACluster(
92-
n_workers=3, dashboard_address=None
93-
) as cluster,
94-
cluster.get_client(),
95-
):
96-
# Repro Issue#3913
97-
df = cudf.DataFrame({"a": [1, 2, 3, 4], "b": [5, 1, 2, 5]})
98-
dask_df = dask_cudf.from_cudf(df, npartitions=2)
99-
dask_df_g = dask_df.groupby(["a"]).b.sum().compute()
89+
with (
90+
dask_cuda.LocalCUDACluster(
91+
n_workers=3, dashboard_address=None
92+
) as cluster,
93+
cluster.get_client(),
94+
):
95+
# Repro Issue#3913
96+
df = cudf.DataFrame({"a": [1, 2, 3, 4], "b": [5, 1, 2, 5]})
97+
dask_df = dask_cudf.from_cudf(df, npartitions=2)
98+
dask_df_g = dask_df.groupby(["a"]).b.sum().compute()
10099

101-
assert dask_df_g.name == "b"
100+
assert dask_df_g.name == "b"
102101

103102

104103
@pytest.mark.usefixtures("dask_client")
@@ -141,24 +140,22 @@ def test_p2p_shuffle():
141140
reason="Machine does not have three GPUs",
142141
)
143142
@pytest.mark.filterwarnings("ignore::ResourceWarning")
143+
@pytest.mark.filterwarnings("ignore:Port")
144144
def test_unique():
145145
# Using `"p2p"` can produce dispatching problems
146146
# TODO: Test "p2p" after dask > 2024.4.1 is required
147147
# See: https://github.com/dask/dask/pull/11040
148-
with warnings.catch_warnings():
149-
warnings.filterwarnings("ignore", category=Warning, message="Port")
150-
151-
with dask_cuda.LocalCUDACluster(
152-
n_workers=3, dashboard_address=None
153-
) as cluster:
154-
with Client(cluster):
155-
df = cudf.DataFrame({"x": ["a", "b", "c", "a", "a"]})
156-
ddf = dask_cudf.from_cudf(df, npartitions=2)
157-
dd.assert_eq(
158-
df.x.unique(),
159-
ddf.x.unique().compute(),
160-
check_index=False,
161-
)
148+
with dask_cuda.LocalCUDACluster(
149+
n_workers=3, dashboard_address=None
150+
) as cluster:
151+
with Client(cluster):
152+
df = cudf.DataFrame({"x": ["a", "b", "c", "a", "a"]})
153+
ddf = dask_cudf.from_cudf(df, npartitions=2)
154+
dd.assert_eq(
155+
df.x.unique(),
156+
ddf.x.unique().compute(),
157+
check_index=False,
158+
)
162159

163160

164161
@pytest.mark.usefixtures("dask_client")

0 commit comments

Comments
 (0)