Skip to content

Commit 60cc2f3

Browse files
authored
TST: Fix warnings & skip -> xfail (#46370)
1 parent a0b99ef commit 60cc2f3

14 files changed

+52
-59
lines changed

azure-pipelines.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
/opt/python/cp38-cp38/bin/python -m venv ~/virtualenvs/pandas-dev && \
4646
. ~/virtualenvs/pandas-dev/bin/activate && \
4747
python -m pip install --no-deps -U pip wheel 'setuptools<60.0.0' && \
48-
pip install cython numpy python-dateutil pytz pytest pytest-xdist hypothesis && \
48+
pip install cython numpy python-dateutil pytz pytest pytest-xdist pytest-asyncio hypothesis && \
4949
python setup.py build_ext -q -j2 && \
5050
python -m pip install --no-build-isolation -e . && \
5151
pytest -m 'not slow and not network and not clipboard and not single_cpu' pandas --junitxml=test-data.xml"

ci/deps/actions-310-numpydev.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ dependencies:
99
- pytest-cov
1010
- pytest-xdist>=1.31
1111
- hypothesis>=5.5.3
12+
- pytest-asyncio
1213

1314
# pandas dependencies
1415
- python-dateutil

ci/deps/circle-38-arm64.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ dependencies:
99
- pytest>=6.0
1010
- pytest-xdist>=1.31
1111
- hypothesis>=5.5.3
12+
- pytest-asyncio
1213

1314
# pandas dependencies
1415
- botocore>=1.11

pandas/tests/arrays/string_/test_string.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ def test_memory_usage(dtype):
523523
# GH 33963
524524

525525
if dtype.storage == "pyarrow":
526-
pytest.skip("not applicable")
526+
pytest.skip(f"not applicable for {dtype.storage}")
527527

528528
series = pd.Series(["a", "b", "c"], dtype=dtype)
529529

pandas/tests/extension/base/ops.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -114,17 +114,22 @@ def test_add_series_with_extension_array(self, data):
114114
self.assert_series_equal(result, expected)
115115

116116
@pytest.mark.parametrize("box", [pd.Series, pd.DataFrame])
117-
def test_direct_arith_with_ndframe_returns_not_implemented(self, data, box):
117+
def test_direct_arith_with_ndframe_returns_not_implemented(
118+
self, request, data, box
119+
):
118120
# EAs should return NotImplemented for ops with Series/DataFrame
119121
# Pandas takes care of unboxing the series and calling the EA's op.
120122
other = pd.Series(data)
121123
if box is pd.DataFrame:
122124
other = other.to_frame()
123-
if hasattr(data, "__add__"):
124-
result = data.__add__(other)
125-
assert result is NotImplemented
126-
else:
127-
raise pytest.skip(f"{type(data).__name__} does not implement add")
125+
if not hasattr(data, "__add__"):
126+
request.node.add_marker(
127+
pytest.mark.xfail(
128+
reason=f"{type(data).__name__} does not implement add"
129+
)
130+
)
131+
result = data.__add__(other)
132+
assert result is NotImplemented
128133

129134

130135
class BaseComparisonOpsTests(BaseOpsUtil):

pandas/tests/extension/json/test_json.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,10 @@ def test_contains(self, data):
156156

157157

158158
class TestConstructors(BaseJSON, base.BaseConstructorsTests):
159-
@pytest.mark.skip(reason="not implemented constructor from dtype")
159+
@pytest.mark.xfail(reason="not implemented constructor from dtype")
160160
def test_from_dtype(self, data):
161161
# construct from our dtype & string dtype
162-
pass
162+
super(self).test_from_dtype(data)
163163

164164
@pytest.mark.xfail(reason="RecursionError, GH-33900")
165165
def test_series_constructor_no_data_with_index(self, dtype, na_value):

pandas/tests/extension/test_categorical.py

+4-14
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def data():
5050
"""Length-100 array for this type.
5151
5252
* data[0] and data[1] should both be non missing
53-
* data[0] and data[1] should not gbe equal
53+
* data[0] and data[1] should not be equal
5454
"""
5555
return Categorical(make_data())
5656

@@ -86,7 +86,7 @@ class TestDtype(base.BaseDtypeTests):
8686

8787

8888
class TestInterface(base.BaseInterfaceTests):
89-
@pytest.mark.skip(reason="Memory usage doesn't match")
89+
@pytest.mark.xfail(reason="Memory usage doesn't match")
9090
def test_memory_usage(self, data):
9191
# Is this deliberate?
9292
super().test_memory_usage(data)
@@ -149,21 +149,15 @@ class TestIndex(base.BaseIndexTests):
149149

150150

151151
class TestMissing(base.BaseMissingTests):
152-
@pytest.mark.skip(reason="Not implemented")
153-
def test_fillna_limit_pad(self, data_missing):
154-
super().test_fillna_limit_pad(data_missing)
155-
156-
@pytest.mark.skip(reason="Not implemented")
157-
def test_fillna_limit_backfill(self, data_missing):
158-
super().test_fillna_limit_backfill(data_missing)
152+
pass
159153

160154

161155
class TestReduce(base.BaseNoReduceTests):
162156
pass
163157

164158

165159
class TestMethods(base.BaseMethodsTests):
166-
@pytest.mark.skip(reason="Unobserved categories included")
160+
@pytest.mark.xfail(reason="Unobserved categories included")
167161
def test_value_counts(self, all_data, dropna):
168162
return super().test_value_counts(all_data, dropna)
169163

@@ -184,10 +178,6 @@ def test_combine_add(self, data_repeated):
184178
expected = pd.Series([a + val for a in list(orig_data1)])
185179
self.assert_series_equal(result, expected)
186180

187-
@pytest.mark.skip(reason="Not Applicable")
188-
def test_fillna_length_mismatch(self, data_missing):
189-
super().test_fillna_length_mismatch(data_missing)
190-
191181

192182
class TestCasting(base.BaseCastingTests):
193183
@pytest.mark.parametrize("cls", [Categorical, CategoricalIndex])

pandas/tests/extension/test_datetime.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,7 @@ class TestMissing(BaseDatetimeTests, base.BaseMissingTests):
175175

176176

177177
class TestReshaping(BaseDatetimeTests, base.BaseReshapingTests):
178-
@pytest.mark.skip(reason="We have DatetimeTZBlock")
179-
def test_concat(self, data, in_frame):
180-
pass
178+
pass
181179

182180

183181
class TestSetitem(BaseDatetimeTests, base.BaseSetitemTests):

pandas/tests/extension/test_interval.py

+13-11
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@ def test_reduce_series_numeric(self, data, all_numeric_reductions, skipna):
121121

122122

123123
class TestMethods(BaseInterval, base.BaseMethodsTests):
124-
@pytest.mark.skip(reason="addition is not defined for intervals")
124+
@pytest.mark.xfail(reason="addition is not defined for intervals")
125125
def test_combine_add(self, data_repeated):
126-
pass
126+
super().test_combine_add(data_repeated)
127127

128128
@pytest.mark.xfail(
129129
reason="Raises with incorrect message bc it disallows *all* listlikes "
@@ -134,29 +134,31 @@ def test_fillna_length_mismatch(self, data_missing):
134134

135135

136136
class TestMissing(BaseInterval, base.BaseMissingTests):
137-
# Index.fillna only accepts scalar `value`, so we have to skip all
137+
# Index.fillna only accepts scalar `value`, so we have to xfail all
138138
# non-scalar fill tests.
139-
unsupported_fill = pytest.mark.skip("Unsupported fillna option.")
139+
unsupported_fill = pytest.mark.xfail(
140+
reason="Unsupported fillna option for Interval."
141+
)
140142

141143
@unsupported_fill
142144
def test_fillna_limit_pad(self):
143-
pass
145+
super().test_fillna_limit_pad()
144146

145147
@unsupported_fill
146148
def test_fillna_series_method(self):
147-
pass
149+
super().test_fillna_series_method()
148150

149151
@unsupported_fill
150152
def test_fillna_limit_backfill(self):
151-
pass
153+
super().test_fillna_limit_backfill()
152154

153155
@unsupported_fill
154156
def test_fillna_no_op_returns_copy(self):
155-
pass
157+
super().test_fillna_no_op_returns_copy()
156158

157159
@unsupported_fill
158160
def test_fillna_series(self):
159-
pass
161+
super().test_fillna_series()
160162

161163
def test_fillna_non_scalar_raises(self, data_missing):
162164
msg = "can only insert Interval objects and NA into an IntervalArray"
@@ -173,9 +175,9 @@ class TestSetitem(BaseInterval, base.BaseSetitemTests):
173175

174176

175177
class TestPrinting(BaseInterval, base.BasePrintingTests):
176-
@pytest.mark.skip(reason="custom repr")
178+
@pytest.mark.xfail(reason="Interval has custom repr")
177179
def test_array_repr(self, data, size):
178-
pass
180+
super().test_array_repr()
179181

180182

181183
class TestParsing(BaseInterval, base.BaseParsingTests):

pandas/tests/extension/test_numpy.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,15 @@ def test_series_constructor_scalar_with_index(self, data, dtype):
208208

209209

210210
class TestDtype(BaseNumPyTests, base.BaseDtypeTests):
211-
@pytest.mark.skip(reason="Incorrect expected.")
212-
# we unsurprisingly clash with a NumPy name.
213-
def test_check_dtype(self, data):
214-
pass
211+
def test_check_dtype(self, data, request):
212+
if data.dtype.numpy_dtype == "object":
213+
request.node.add_marker(
214+
pytest.mark.xfail(
215+
reason=f"PandasArray expectedly clashes with a "
216+
f"NumPy name: {data.dtype.numpy_dtype}"
217+
)
218+
)
219+
super().test_check_dtype(data)
215220

216221

217222
class TestGetitem(BaseNumPyTests, base.BaseGetitemTests):
@@ -345,11 +350,6 @@ def test_fillna_frame(self, data_missing):
345350

346351

347352
class TestReshaping(BaseNumPyTests, base.BaseReshapingTests):
348-
@pytest.mark.skip(reason="Incorrect expected.")
349-
def test_merge(self, data, na_value):
350-
# Fails creating expected (key column becomes a PandasDtype because)
351-
super().test_merge(data, na_value)
352-
353353
@pytest.mark.parametrize(
354354
"in_frame",
355355
[

pandas/tests/extension/test_string.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
def split_array(arr):
2828
if arr.dtype.storage != "pyarrow":
29-
pytest.skip("chunked array n/a")
29+
pytest.skip("only applicable for pyarrow chunked array n/a")
3030

3131
def _split_array(arr):
3232
import pyarrow as pa
@@ -156,13 +156,9 @@ def test_reduce_series_numeric(self, data, all_numeric_reductions, skipna):
156156

157157

158158
class TestMethods(base.BaseMethodsTests):
159-
@pytest.mark.skip(reason="returns nullable")
160-
def test_value_counts(self, all_data, dropna):
161-
return super().test_value_counts(all_data, dropna)
162-
163-
@pytest.mark.skip(reason="returns nullable")
159+
@pytest.mark.xfail(reason="returns nullable: GH 44692")
164160
def test_value_counts_with_normalize(self, data):
165-
pass
161+
super().test_value_counts_with_normalize(data)
166162

167163

168164
class TestCasting(base.BaseCastingTests):

pandas/tests/plotting/frame/test_frame.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,11 @@ def test_nullable_int_plot(self):
146146
df = DataFrame(
147147
{
148148
"A": [1, 2, 3, 4, 5],
149-
"B": [1.0, 2.0, 3.0, 4.0, 5.0],
150-
"C": [7, 5, np.nan, 3, 2],
149+
"B": [1, 2, 3, 4, 5],
150+
"C": np.array([7, 5, np.nan, 3, 2], dtype=object),
151151
"D": pd.to_datetime(dates, format="%Y").view("i8"),
152152
"E": pd.to_datetime(dates, format="%Y", utc=True).view("i8"),
153-
},
154-
dtype=np.int64,
153+
}
155154
)
156155

157156
_check_plot_works(df.plot, x="A", y="B")

pandas/tests/plotting/test_converter.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ def test_conversion(self):
327327

328328
rs = self.pc.convert(
329329
np.array(
330-
["2012-01-01 00:00:00+0000", "2012-01-02 00:00:00+0000"],
330+
["2012-01-01 00:00:00", "2012-01-02 00:00:00"],
331331
dtype="datetime64[ns]",
332332
),
333333
None,

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ markers = [
5656
"arm_slow: mark a test as slow for arm64 architecture",
5757
"arraymanager: mark a test to run with ArrayManager enabled",
5858
]
59+
asyncio_mode = "strict"
5960

6061
[tool.mypy]
6162
# Import discovery

0 commit comments

Comments
 (0)