Skip to content

Commit 1c309c4

Browse files
authored
CI: conditional xfail flaky test (#39964)
1 parent 2f73c7a commit 1c309c4

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

pandas/tests/io/parser/common/test_chunksize.py

+22-3
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def test_chunks_have_consistent_numerical_type(all_parsers):
173173
assert result.a.dtype == float
174174

175175

176-
def test_warn_if_chunks_have_mismatched_type(all_parsers):
176+
def test_warn_if_chunks_have_mismatched_type(all_parsers, request):
177177
warning_type = None
178178
parser = all_parsers
179179
integers = [str(i) for i in range(499999)]
@@ -184,8 +184,27 @@ def test_warn_if_chunks_have_mismatched_type(all_parsers):
184184
if parser.engine == "c" and parser.low_memory:
185185
warning_type = DtypeWarning
186186

187-
with tm.assert_produces_warning(warning_type):
188-
df = parser.read_csv(StringIO(data))
187+
buf = StringIO(data)
188+
189+
try:
190+
with tm.assert_produces_warning(warning_type):
191+
df = parser.read_csv(buf)
192+
except AssertionError as err:
193+
# 2021-02-21 this occasionally fails on the CI with an unexpected
194+
# ResourceWarning that we have been unable to track down,
195+
# see GH#38630
196+
if "ResourceError" not in str(err) or parser.engine != "python":
197+
raise
198+
199+
# Check the main assertion of the test before re-raising
200+
assert df.a.dtype == object
201+
202+
mark = pytest.mark.xfail(
203+
reason="ResourceWarning for unclosed SSL Socket, GH#38630"
204+
)
205+
request.node.add_marker(mark)
206+
raise
207+
189208
assert df.a.dtype == object
190209

191210

0 commit comments

Comments
 (0)