From 0efa77922086121b08751e3a8ae991d0695e6246 Mon Sep 17 00:00:00 2001 From: Brock Date: Sun, 21 Feb 2021 18:51:33 -0800 Subject: [PATCH] CI: conditional xfail flaky test --- .../tests/io/parser/common/test_chunksize.py | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/pandas/tests/io/parser/common/test_chunksize.py b/pandas/tests/io/parser/common/test_chunksize.py index 3d9d780a1e878..8e1e9fb6e458f 100644 --- a/pandas/tests/io/parser/common/test_chunksize.py +++ b/pandas/tests/io/parser/common/test_chunksize.py @@ -173,7 +173,7 @@ def test_chunks_have_consistent_numerical_type(all_parsers): assert result.a.dtype == float -def test_warn_if_chunks_have_mismatched_type(all_parsers): +def test_warn_if_chunks_have_mismatched_type(all_parsers, request): warning_type = None parser = all_parsers integers = [str(i) for i in range(499999)] @@ -184,8 +184,27 @@ def test_warn_if_chunks_have_mismatched_type(all_parsers): if parser.engine == "c" and parser.low_memory: warning_type = DtypeWarning - with tm.assert_produces_warning(warning_type): - df = parser.read_csv(StringIO(data)) + buf = StringIO(data) + + try: + with tm.assert_produces_warning(warning_type): + df = parser.read_csv(buf) + except AssertionError as err: + # 2021-02-21 this occasionally fails on the CI with an unexpected + # ResourceWarning that we have been unable to track down, + # see GH#38630 + if "ResourceError" not in str(err) or parser.engine != "python": + raise + + # Check the main assertion of the test before re-raising + assert df.a.dtype == object + + mark = pytest.mark.xfail( + reason="ResourceWarning for unclosed SSL Socket, GH#38630" + ) + request.node.add_marker(mark) + raise + assert df.a.dtype == object