Skip to content

Backport PR #56818 on branch 2.2.x (CI: Fix failing builds) #56819

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
Show file tree
Hide file tree
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
17 changes: 4 additions & 13 deletions pandas/tests/io/parser/common/test_chunksize.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,9 @@ def test_chunks_have_consistent_numerical_type(all_parsers, monkeypatch):
data = "a\n" + "\n".join(integers + ["1.0", "2.0"] + integers)

# Coercions should work without warnings.
warn = None
if parser.engine == "pyarrow":
warn = DeprecationWarning
depr_msg = "Passing a BlockManager to DataFrame|make_block is deprecated"
with tm.assert_produces_warning(warn, match=depr_msg, check_stacklevel=False):
with monkeypatch.context() as m:
m.setattr(libparsers, "DEFAULT_BUFFER_HEURISTIC", heuristic)
result = parser.read_csv(StringIO(data))
with monkeypatch.context() as m:
m.setattr(libparsers, "DEFAULT_BUFFER_HEURISTIC", heuristic)
result = parser.read_csv(StringIO(data))

assert type(result.a[0]) is np.float64
assert result.a.dtype == float
Expand All @@ -251,12 +246,8 @@ def test_warn_if_chunks_have_mismatched_type(all_parsers):
buf = StringIO(data)

if parser.engine == "pyarrow":
df = parser.read_csv_check_warnings(
DeprecationWarning,
"Passing a BlockManager to DataFrame is deprecated|"
"make_block is deprecated",
df = parser.read_csv(
buf,
check_stacklevel=False,
)
else:
df = parser.read_csv_check_warnings(
Expand Down
17 changes: 3 additions & 14 deletions pandas/tests/io/parser/common/test_read_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,9 @@ def test_catch_too_many_names(all_parsers):
else "Number of passed names did not match "
"number of header fields in the file"
)
depr_msg = "Passing a BlockManager to DataFrame is deprecated"
warn = None
if parser.engine == "pyarrow":
warn = DeprecationWarning

with tm.assert_produces_warning(warn, match=depr_msg, check_stacklevel=False):
with pytest.raises(ValueError, match=msg):
parser.read_csv(StringIO(data), header=0, names=["a", "b", "c", "d"])
with pytest.raises(ValueError, match=msg):
parser.read_csv(StringIO(data), header=0, names=["a", "b", "c", "d"])


@skip_pyarrow # CSV parse error: Empty CSV file or block
Expand Down Expand Up @@ -168,13 +163,7 @@ def test_suppress_error_output(all_parsers):
data = "a\n1\n1,2,3\n4\n5,6,7"
expected = DataFrame({"a": [1, 4]})

warn = None
if parser.engine == "pyarrow":
warn = DeprecationWarning
msg = "Passing a BlockManager to DataFrame|make_block is deprecated"

with tm.assert_produces_warning(warn, match=msg, check_stacklevel=False):
result = parser.read_csv(StringIO(data), on_bad_lines="skip")
result = parser.read_csv(StringIO(data), on_bad_lines="skip")
tm.assert_frame_equal(result, expected)


Expand Down