Skip to content

Commit c2e0881

Browse files
timsaucerclaude
andcommitted
test: capture deprecation warning in repr_rows conflict case
DataFrameHtmlFormatter(repr_rows=..., max_rows=...) fires the deprecation warning before raising ValueError, but pytest.raises does not catch warnings. The escaping warning surfaced in every pytest run. Wrap the call in both pytest.raises and pytest.warns so the warning is asserted, not leaked. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 3c052ef commit c2e0881

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

python/tests/test_dataframe.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1704,8 +1704,12 @@ def test_repr_rows_backward_compatibility(clean_formatter_state):
17041704
assert formatter.max_rows == 15
17051705
assert formatter.repr_rows == 15
17061706

1707-
# Should fail when conflicting with max_rows
1708-
with pytest.raises(ValueError, match="Cannot specify both repr_rows and max_rows"):
1707+
# Should fail when conflicting with max_rows. The deprecation warning still
1708+
# fires before the ValueError, so assert both.
1709+
with (
1710+
pytest.raises(ValueError, match="Cannot specify both repr_rows and max_rows"),
1711+
pytest.warns(DeprecationWarning, match="repr_rows parameter is deprecated"),
1712+
):
17091713
DataFrameHtmlFormatter(repr_rows=5, max_rows=10)
17101714

17111715
# Setting repr_rows via property should warn

0 commit comments

Comments
 (0)