Skip to content

TST/CI: speed up chunksize test #42174

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 8 additions & 20 deletions pandas/tests/io/parser/common/test_chunksize.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,34 +177,22 @@ def test_chunks_have_consistent_numerical_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)]
data = "a\n" + "\n".join(integers + ["a", "b"] + integers)
size = 10000

# see gh-3866: if chunks are different types and can't
# be coerced using numerical types, then issue warning.
if parser.engine == "c" and parser.low_memory:
warning_type = DtypeWarning
# Use larger size to hit warning path
size = 499999

integers = [str(i) for i in range(size)]
data = "a\n" + "\n".join(integers + ["a", "b"] + integers)

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 "ResourceWarning" 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
with tm.assert_produces_warning(warning_type):
df = parser.read_csv(buf)

assert df.a.dtype == object

Expand Down