Skip to content

Commit

Permalink
Backport PR pandas-dev#56818: CI: Fix failing builds
Browse files Browse the repository at this point in the history
  • Loading branch information
lithomas1 authored and meeseeksmachine committed Jan 11, 2024
1 parent e28b401 commit 43e1f5f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 27 deletions.
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 @@ -252,12 +247,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

0 comments on commit 43e1f5f

Please sign in to comment.