@@ -1649,7 +1649,7 @@ def test_html_formatter_manual_format_html(clean_formatter_state):
1649
1649
assert "<style>" in local_html_2
1650
1650
1651
1651
1652
- def test_html_formatter_memory_and_row_parameters ():
1652
+ def test_html_formatter_memory_and_rows ():
1653
1653
"""Test the memory and row control parameters in DataFrameHtmlFormatter."""
1654
1654
1655
1655
# Test default values
@@ -1667,26 +1667,20 @@ def test_html_formatter_memory_and_row_parameters():
1667
1667
assert formatter .max_memory_bytes == 1024 * 1024
1668
1668
assert formatter .min_rows_display == 10
1669
1669
assert formatter .repr_rows == 5
1670
-
1671
-
1672
- def test_html_formatter_memory_and_row_validation ():
1673
- """Test validation for the memory and row control parameters in DataFrameHtmlFormatter."""
1674
1670
1675
- # Test invalid max_memory_bytes
1671
+ # Test validation for invalid parameters
1676
1672
with pytest .raises (ValueError , match = "max_memory_bytes must be a positive integer" ):
1677
1673
DataFrameHtmlFormatter (max_memory_bytes = 0 )
1678
1674
1679
1675
with pytest .raises (ValueError , match = "max_memory_bytes must be a positive integer" ):
1680
1676
DataFrameHtmlFormatter (max_memory_bytes = - 100 )
1681
1677
1682
- # Test invalid min_rows_display
1683
1678
with pytest .raises (ValueError , match = "min_rows_display must be a positive integer" ):
1684
1679
DataFrameHtmlFormatter (min_rows_display = 0 )
1685
1680
1686
1681
with pytest .raises (ValueError , match = "min_rows_display must be a positive integer" ):
1687
1682
DataFrameHtmlFormatter (min_rows_display = - 5 )
1688
1683
1689
- # Test invalid repr_rows
1690
1684
with pytest .raises (ValueError , match = "repr_rows must be a positive integer" ):
1691
1685
DataFrameHtmlFormatter (repr_rows = 0 )
1692
1686
@@ -1710,7 +1704,20 @@ def get_header_style(self) -> str:
1710
1704
"padding: 10px; border: 1px solid #3367d6;"
1711
1705
)
1712
1706
1713
- # Configure with custom style provider and memory/row parameters
1707
+ # Configure with custom style provider
1708
+ configure_formatter (style_provider = CustomStyleProvider ())
1709
+
1710
+ html_output = df ._repr_html_ ()
1711
+
1712
+ # Verify our custom styles were applied
1713
+ assert "background-color: #4285f4" in html_output
1714
+ assert "color: white" in html_output
1715
+ assert "background-color: #f5f5f5" in html_output
1716
+
1717
+ # Reset for the next part of the test
1718
+ reset_formatter ()
1719
+
1720
+ # Configure with custom style provider and additional parameters
1714
1721
configure_formatter (
1715
1722
style_provider = CustomStyleProvider (),
1716
1723
max_memory_bytes = 3 * 1024 * 1024 , # 3 MB
@@ -1725,7 +1732,7 @@ def get_header_style(self) -> str:
1725
1732
assert "color: white" in html_output
1726
1733
assert "background-color: #f5f5f5" in html_output
1727
1734
1728
- # Test memory and row parameters
1735
+ # Test memory and row parameters were properly set
1729
1736
formatter = get_formatter ()
1730
1737
assert formatter .max_memory_bytes == 3 * 1024 * 1024 # 3 MB
1731
1738
assert formatter .min_rows_display == 15
0 commit comments