2929 literal ,
3030)
3131from datafusion import functions as f
32+ from datafusion .context import DataframeDisplayConfig
3233from datafusion .expr import Window
3334from pyarrow .csv import write_csv
34- from datafusion .context import DataframeDisplayConfig
3535
3636
3737@pytest .fixture
@@ -57,6 +57,11 @@ def data():
5757 return [{"a" : 1 , "b" : "x" * 50 , "c" : 3 }] * 100
5858
5959
60+ @pytest .fixture
61+ def span_expandable_class ():
62+ return '<span class="expandable" id="'
63+
64+
6065def test_display_config ():
6166 # Test display_config initialization
6267 config = DataframeDisplayConfig (
@@ -98,7 +103,7 @@ def test_display_config():
98103 config .max_table_rows_in_repr = - 5
99104
100105
101- def test_session_with_display_config (data ):
106+ def test_session_with_display_config (data , span_expandable_class ):
102107 # Test with_display_config returns a new context with updated config
103108 ctx = SessionContext ()
104109
@@ -121,19 +126,14 @@ def test_session_with_display_config(data):
121126 # The HTML representation should be different with different display configs
122127 assert html_repr != html_repr2
123128
124- # Check that the second representation has the short cell data based on the configured length
125- assert f'<span class="expandable" id="' in html_repr2
126- assert f'>{ ("x" * 10 )} </span>' in html_repr2
129+ # Check that the second representation has the short cell data based on the
130+ # configured length
131+ assert span_expandable_class in html_repr2
132+ assert f">{ ('x' * 10 )} </span>" in html_repr2
127133
128134
129135def test_display_config_in_init (data ):
130- # Test providing display config directly in SessionContext constructor
131- display_config = DataframeDisplayConfig (
132- max_table_bytes = 1024 ,
133- min_table_rows = 5 ,
134- max_cell_length = 10 ,
135- max_table_rows_in_repr = 3 ,
136- )
136+ # Test default display config directly in SessionContext constructor
137137
138138 ctx = SessionContext ()
139139 df1 = ctx .from_pylist (data )
@@ -1403,7 +1403,7 @@ def test_display_config_affects_repr(data):
14031403 assert "Data truncated" not in repr_str2
14041404
14051405
1406- def test_display_config_affects_html_repr (data ):
1406+ def test_display_config_affects_html_repr (data , span_expandable_class ):
14071407 # Create a context with custom display config to show only a small cell length
14081408 ctx = SessionContext ().with_display_config (max_cell_length = 5 )
14091409
@@ -1415,8 +1415,7 @@ def test_display_config_affects_html_repr(data):
14151415
14161416 # The cell should be truncated to 5 characters and have expansion button
14171417 assert ">xxxxx" in html_str # 5 character limit
1418- expandable_class = 'class="expandable-container"'
1419- assert expandable_class in html_str
1418+ assert span_expandable_class in html_str
14201419
14211420 # Create a context with larger cell length limit
14221421 ctx2 = SessionContext ().with_display_config (max_cell_length = 60 )
@@ -1425,7 +1424,7 @@ def test_display_config_affects_html_repr(data):
14251424 html_str2 = df2 ._repr_html_ ()
14261425
14271426 # String shouldn't be truncated (or at least not in the same way)
1428- assert expandable_class not in html_str2
1427+ assert span_expandable_class not in html_str2
14291428
14301429
14311430def test_display_config_rows_limit_in_html (data ):
0 commit comments