Skip to content

Commit da116bf

Browse files
committed
reuse _create_numeric_test_df
1 parent 52091ce commit da116bf

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

python/tests/test_dataframe.py

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,18 +1298,9 @@ def test_configure_display(df):
12981298
with pytest.raises(ValueError, match=r".*must be greater than 0.*"):
12991299
df.configure_display(max_table_bytes=0, min_table_rows=0, max_cell_length=0)
13001300

1301-
# Very large values
1302-
df.configure_display(
1303-
max_table_bytes=10**12, min_table_rows=10**6, max_cell_length=10**4
1304-
)
1305-
config = df.display_config
1306-
assert config.max_table_bytes == 10**12 # 1 TB
1307-
assert config.min_table_rows == 10**6 # 1 million rows
1308-
assert config.max_cell_length == 10**4 # 10,000 chars per cell
1309-
13101301
# Test with negative values
13111302
# This tests for expected behavior when users accidentally pass negative values
1312-
# Since these are usize in Rust, we expect a Python TypeError when trying to pass negative values
1303+
# Since these are usize in Rust, we expect a Python ValueError when trying to pass negative values
13131304
with pytest.raises(ValueError, match=r".*must be greater than 0.*"):
13141305
df.configure_display(max_table_bytes=-1)
13151306

@@ -1348,9 +1339,7 @@ def test_min_table_rows_display(ctx):
13481339
"""Test that at least min_table_rows rows are displayed."""
13491340
# Create a dataframe with more rows than the default min_table_rows
13501341
rows = 100
1351-
data = list(range(rows))
1352-
batch = pa.RecordBatch.from_arrays([pa.array(data)], names=["values"])
1353-
df = ctx.create_dataframe([[batch]])
1342+
df = _create_numeric_test_df(ctx, rows)
13541343

13551344
# Set min_table_rows to a specific value
13561345
custom_min_rows = 30
@@ -1433,7 +1422,7 @@ def test_max_cell_length_display(ctx):
14331422
def test_display_config_repr_string(ctx):
14341423
"""Test that __repr__ respects display configuration."""
14351424
# Create a dataframe with more rows than we want to show
1436-
# df.__repr__ returns max 10 rows only, so we start test with 7 rows
1425+
# df.__repr__ returns max 10 rows, so we start test with 7 rows
14371426
rows = 7
14381427
df = _create_numeric_test_df(ctx, rows)
14391428

@@ -1469,7 +1458,7 @@ def test_display_config_repr_string(ctx):
14691458
assert lines_count2 >= min_table_rows_in_display
14701459

14711460

1472-
def _count_lines_in_str(repr_str):
1461+
def _count_lines_in_str(repr_str: str) -> int:
14731462
"""Count the number of rows displayed in a string representation.
14741463
14751464
Args:
@@ -1488,7 +1477,7 @@ def _count_lines_in_str(repr_str):
14881477
return value_lines
14891478

14901479

1491-
def _create_numeric_test_df(ctx, rows):
1480+
def _create_numeric_test_df(ctx, rows) -> DataFrame:
14921481
"""Create a test dataframe with numeric values from 0 to rows-1.
14931482
14941483
Args:

0 commit comments

Comments
 (0)