Skip to content

Commit

Permalink
fixup more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jorisvandenbossche committed Oct 26, 2023
1 parent 54a8591 commit 9042d97
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 20 deletions.
21 changes: 9 additions & 12 deletions pandas/tests/arrays/period/test_arrow_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
period_array,
)

pytestmark = pytest.mark.filterwarnings(
"ignore:Passing a BlockManager to DataFrame:DeprecationWarning"
)


pa = pytest.importorskip("pyarrow")


Expand Down Expand Up @@ -81,16 +86,12 @@ def test_arrow_table_roundtrip():

table = pa.table(df)
assert isinstance(table.field("a").type, ArrowPeriodType)
msg = "Passing a BlockManager to DataFrame is deprecated"
with tm.assert_produces_warning(DeprecationWarning, match=msg):
result = table.to_pandas()
result = table.to_pandas()
assert isinstance(result["a"].dtype, PeriodDtype)
tm.assert_frame_equal(result, df)

table2 = pa.concat_tables([table, table])
msg = "Passing a BlockManager to DataFrame is deprecated"
with tm.assert_produces_warning(DeprecationWarning, match=msg):
result = table2.to_pandas()
result = table2.to_pandas()
expected = pd.concat([df, df], ignore_index=True)
tm.assert_frame_equal(result, expected)

Expand All @@ -109,9 +110,7 @@ def test_arrow_load_from_zero_chunks():
[pa.chunked_array([], type=table.column(0).type)], schema=table.schema
)

msg = "Passing a BlockManager to DataFrame is deprecated"
with tm.assert_produces_warning(DeprecationWarning, match=msg):
result = table.to_pandas()
result = table.to_pandas()
assert isinstance(result["a"].dtype, PeriodDtype)
tm.assert_frame_equal(result, df)

Expand All @@ -126,8 +125,6 @@ def test_arrow_table_roundtrip_without_metadata():
table = table.replace_schema_metadata()
assert table.schema.metadata is None

msg = "Passing a BlockManager to DataFrame is deprecated"
with tm.assert_produces_warning(DeprecationWarning, match=msg):
result = table.to_pandas()
result = table.to_pandas()
assert isinstance(result["a"].dtype, PeriodDtype)
tm.assert_frame_equal(result, df)
11 changes: 3 additions & 8 deletions pandas/tests/io/parser/test_parse_dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -2230,14 +2230,9 @@ def test_parse_dates_dict_format_two_columns(all_parsers, key, parse_dates):
31-,12-2019
31-,12-2020"""

warn = None
if parser.engine == "pyarrow":
warn = DeprecationWarning
msg = "Passing a BlockManager to DataFrame is deprecated"
with tm.assert_produces_warning(warn, match=msg, check_stacklevel=False):
result = parser.read_csv(
StringIO(data), date_format={key: "%d- %m-%Y"}, parse_dates=parse_dates
)
result = parser.read_csv(
StringIO(data), date_format={key: "%d- %m-%Y"}, parse_dates=parse_dates
)
expected = DataFrame(
{
key: [Timestamp("2019-12-31"), Timestamp("2020-12-31")],
Expand Down

0 comments on commit 9042d97

Please sign in to comment.