Skip to content

Commit 5aae267

Browse files
committed
feat: Add display configuration tests for DataFrame
- Implemented tests for accessing and modifying display configuration properties in the DataFrame class. - Added `test_display_config` to verify default values of display settings. - Created `test_configure_display` to test setting and partially updating display configuration. - Introduced `test_reset_display_config` to ensure resetting configuration restores default values.
1 parent fd8f5a1 commit 5aae267

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

python/tests/test_dataframe.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,3 +1261,55 @@ def test_dataframe_repr_html(df) -> None:
12611261
body_lines = [f"<td(.*?)>{v}</td>" for inner in body_data for v in inner]
12621262
body_pattern = "(.*?)".join(body_lines)
12631263
assert len(re.findall(body_pattern, output, re.DOTALL)) == 1
1264+
1265+
1266+
def test_display_config(df):
1267+
"""Test the display configuration properties are accessible."""
1268+
config = df.display_config
1269+
1270+
# Verify default values
1271+
assert config.max_table_bytes == 2 * 1024 * 1024 # 2 MB
1272+
assert config.min_table_rows == 20
1273+
assert config.max_cell_length == 25
1274+
1275+
1276+
def test_configure_display(df):
1277+
"""Test setting display configuration properties."""
1278+
# Modify the display configuration
1279+
df.configure_display(
1280+
max_table_bytes=1024 * 1024, min_table_rows=10, max_cell_length=50 # 1 MB
1281+
)
1282+
1283+
# Verify the changes took effect
1284+
config = df.display_config
1285+
assert config.max_table_bytes == 1024 * 1024 # 1 MB
1286+
assert config.min_table_rows == 10
1287+
assert config.max_cell_length == 50
1288+
1289+
# Test partial update (only changing one property)
1290+
df.configure_display(min_table_rows=5)
1291+
config = df.display_config
1292+
assert config.max_table_bytes == 1024 * 1024 # previous value retained
1293+
assert config.min_table_rows == 5 # only this value changed
1294+
assert config.max_cell_length == 50 # previous value retained
1295+
1296+
1297+
def test_reset_display_config(df):
1298+
"""Test resetting display configuration to defaults."""
1299+
# First modify the configuration
1300+
df.configure_display(
1301+
max_table_bytes=1024 * 1024, min_table_rows=10, max_cell_length=50
1302+
)
1303+
1304+
# Verify changes took effect
1305+
config = df.display_config
1306+
assert config.max_table_bytes == 1024 * 1024
1307+
1308+
# Now reset to defaults
1309+
df.reset_display_config()
1310+
1311+
# Verify defaults are restored
1312+
config = df.display_config
1313+
assert config.max_table_bytes == 2 * 1024 * 1024 # 2 MB
1314+
assert config.min_table_rows == 20
1315+
assert config.max_cell_length == 25

0 commit comments

Comments
 (0)