Skip to content

Commit

Permalink
use stacklevel of 1
Browse files Browse the repository at this point in the history
  • Loading branch information
jorisvandenbossche committed Oct 26, 2023
1 parent bdebc9f commit 20dabc5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ def __init__(
"is deprecated and will raise in a future version. "
"Use public APIs instead.",
DeprecationWarning,
stacklevel=2,
stacklevel=1, # bump to 2 once pyarrow is released with fix
)

if using_copy_on_write():
Expand Down
8 changes: 6 additions & 2 deletions pandas/tests/frame/test_block_internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,16 @@ def test_setitem_invalidates_datetime_index_freq(self):

def test_cast_internals(self, float_frame):
msg = "Passing a BlockManager to DataFrame"
with tm.assert_produces_warning(DeprecationWarning, match=msg):
with tm.assert_produces_warning(
DeprecationWarning, match=msg, check_stacklevel=False
):
casted = DataFrame(float_frame._mgr, dtype=int)
expected = DataFrame(float_frame._series, dtype=int)
tm.assert_frame_equal(casted, expected)

with tm.assert_produces_warning(DeprecationWarning, match=msg):
with tm.assert_produces_warning(
DeprecationWarning, match=msg, check_stacklevel=False
):
casted = DataFrame(float_frame._mgr, dtype=np.int32)
expected = DataFrame(float_frame._series, dtype=np.int32)
tm.assert_frame_equal(casted, expected)
Expand Down
4 changes: 3 additions & 1 deletion pandas/tests/frame/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1742,7 +1742,9 @@ def test_constructor_manager_resize(self, float_frame):
columns = list(float_frame.columns[:3])

msg = "Passing a BlockManager to DataFrame"
with tm.assert_produces_warning(DeprecationWarning, match=msg):
with tm.assert_produces_warning(
DeprecationWarning, match=msg, check_stacklevel=False
):
result = DataFrame(float_frame._mgr, index=index, columns=columns)
tm.assert_index_equal(result.index, Index(index))
tm.assert_index_equal(result.columns, Index(columns))
Expand Down
4 changes: 4 additions & 0 deletions pandas/tests/io/parser/test_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
from pandas.io.feather_format import read_feather
from pandas.io.parsers import read_csv

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


@pytest.mark.network
@pytest.mark.single_cpu
Expand Down

0 comments on commit 20dabc5

Please sign in to comment.