@@ -132,10 +132,8 @@ def get_header_style(self) -> str:
132132
133133def count_table_rows (html_content : str ) -> int :
134134 """Count the number of table rows in HTML content.
135-
136135 Args:
137136 html_content: HTML string to analyze
138-
139137 Returns:
140138 Number of table rows found (number of <tr> tags)
141139 """
@@ -934,14 +932,14 @@ def test_html_formatter_memory(df, clean_formatter_state):
934932 min_rows_display = 1
935933 )
936934 html_output = df ._repr_html_ ()
937-
935+
938936 # Count the number of table rows in the output
939937 tr_count = count_table_rows (html_output )
940938 # With a tiny memory limit of 10 bytes, the formatter should display
941939 # the minimum number of rows (1) plus a message about truncation
942940 assert tr_count == 2 # 1 for header row, 1 for data row
943- assert "data truncated" in html_output .lower ()
944-
941+ assert "data truncated" in html_output .lower ()
942+
945943 configure_formatter (
946944 max_memory_bytes = 10 * MB ,
947945 min_rows_display = 1
@@ -960,34 +958,34 @@ def test_html_formatter_repr_rows(df, clean_formatter_state):
960958 repr_rows = 2
961959 )
962960 html_output = df ._repr_html_ ()
963-
961+
964962 tr_count = count_table_rows (html_output )
965963 # Tabe should have header row (1) + 2 data rows = 3 rows
966964 assert tr_count == 3
967-
965+
968966 configure_formatter (
969967 min_rows_display = 2 ,
970968 repr_rows = 3
971969 )
972970 html_output = df ._repr_html_ ()
973-
971+
974972 tr_count = count_table_rows (html_output )
975973 # Tabe should have header row (1) + 3 data rows = 4 rows
976974 assert tr_count == 4
977-
978-
975+
976+
979977def test_html_formatter_validation ():
980978 # Test validation for invalid parameters
981-
979+
982980 with pytest .raises (ValueError , match = "max_cell_length must be a positive integer" ):
983981 DataFrameHtmlFormatter (max_cell_length = 0 )
984-
982+
985983 with pytest .raises (ValueError , match = "max_width must be a positive integer" ):
986984 DataFrameHtmlFormatter (max_width = 0 )
987-
985+
988986 with pytest .raises (ValueError , match = "max_height must be a positive integer" ):
989987 DataFrameHtmlFormatter (max_height = 0 )
990-
988+
991989 with pytest .raises (ValueError , match = "max_memory_bytes must be a positive integer" ):
992990 DataFrameHtmlFormatter (max_memory_bytes = 0 )
993991
@@ -1012,51 +1010,51 @@ def test_configure_formatter(df, clean_formatter_state):
10121010 parameters."""
10131011
10141012 # these are non-default values
1015- MAX_CELL_LENGTH = 10
1016- MAX_WIDTH = 500
1017- MAX_HEIGHT = 30
1018- MAX_MEMORY_BYTES = 3 * MB
1019- MIN_ROWS_DISPLAY = 2
1020- REPR_ROWS = 2
1021- ENABLE_CELL_EXPANSION = False
1022- SHOW_TRUNCATION_MESSAGE = False
1023- USE_SHARED_STYLES = False
1024-
1013+ max_cell_length = 10
1014+ max_width = 500
1015+ max_height = 30
1016+ max_memory_bytes = 3 * MB
1017+ min_rows_display = 2
1018+ repr_rows = 2
1019+ enable_cell_expansion = False
1020+ show_truncation_message = False
1021+ use_shared_styles = False
1022+
10251023 reset_formatter ()
10261024 formatter_default = get_formatter ()
1027-
1028- assert formatter_default .max_cell_length != MAX_CELL_LENGTH
1029- assert formatter_default .max_width != MAX_WIDTH
1030- assert formatter_default .max_height != MAX_HEIGHT
1031- assert formatter_default .max_memory_bytes != MAX_MEMORY_BYTES
1032- assert formatter_default .min_rows_display != MIN_ROWS_DISPLAY
1033- assert formatter_default .repr_rows != REPR_ROWS
1034- assert formatter_default .enable_cell_expansion != ENABLE_CELL_EXPANSION
1035- assert formatter_default .show_truncation_message != SHOW_TRUNCATION_MESSAGE
1036- assert formatter_default .use_shared_styles != USE_SHARED_STYLES
1037-
1025+
1026+ assert formatter_default .max_cell_length != max_cell_length
1027+ assert formatter_default .max_width != max_width
1028+ assert formatter_default .max_height != max_height
1029+ assert formatter_default .max_memory_bytes != max_memory_bytes
1030+ assert formatter_default .min_rows_display != min_rows_display
1031+ assert formatter_default .repr_rows != repr_rows
1032+ assert formatter_default .enable_cell_expansion != enable_cell_expansion
1033+ assert formatter_default .show_truncation_message != show_truncation_message
1034+ assert formatter_default .use_shared_styles != use_shared_styles
1035+
10381036 # Configure with custom style provider and additional parameters
10391037 configure_formatter (
1040- max_cell_length = MAX_CELL_LENGTH ,
1041- max_width = MAX_WIDTH ,
1042- max_height = MAX_HEIGHT ,
1043- max_memory_bytes = MAX_MEMORY_BYTES ,
1044- min_rows_display = MIN_ROWS_DISPLAY ,
1045- repr_rows = REPR_ROWS ,
1046- enable_cell_expansion = ENABLE_CELL_EXPANSION ,
1047- show_truncation_message = SHOW_TRUNCATION_MESSAGE ,
1048- use_shared_styles = USE_SHARED_STYLES
1038+ max_cell_length = max_cell_length ,
1039+ max_width = max_width ,
1040+ max_height = max_height ,
1041+ max_memory_bytes = max_memory_bytes ,
1042+ min_rows_display = min_rows_display ,
1043+ repr_rows = repr_rows ,
1044+ enable_cell_expansion = enable_cell_expansion ,
1045+ show_truncation_message = show_truncation_message ,
1046+ use_shared_styles = use_shared_styles
10491047 )
10501048 formatter_custom = get_formatter ()
1051- assert formatter_custom .max_cell_length == MAX_CELL_LENGTH
1052- assert formatter_custom .max_width == MAX_WIDTH
1053- assert formatter_custom .max_height == MAX_HEIGHT
1054- assert formatter_custom .max_memory_bytes == MAX_MEMORY_BYTES
1055- assert formatter_custom .min_rows_display == MIN_ROWS_DISPLAY
1056- assert formatter_custom .repr_rows == REPR_ROWS
1057- assert formatter_custom .enable_cell_expansion == ENABLE_CELL_EXPANSION
1058- assert formatter_custom .show_truncation_message == SHOW_TRUNCATION_MESSAGE
1059- assert formatter_custom .use_shared_styles == USE_SHARED_STYLES
1049+ assert formatter_custom .max_cell_length == max_cell_length
1050+ assert formatter_custom .max_width == max_width
1051+ assert formatter_custom .max_height == max_height
1052+ assert formatter_custom .max_memory_bytes == max_memory_bytes
1053+ assert formatter_custom .min_rows_display == min_rows_display
1054+ assert formatter_custom .repr_rows == repr_rows
1055+ assert formatter_custom .enable_cell_expansion == enable_cell_expansion
1056+ assert formatter_custom .show_truncation_message == show_truncation_message
1057+ assert formatter_custom .use_shared_styles == use_shared_styles
10601058
10611059
10621060def test_get_dataframe (tmp_path ):
0 commit comments