Skip to content

Commit fb90fbc

Browse files
committed
fix: Update test data size and improve display config tests
- Reduced the size of test data in the `data` fixture from 100 to 10 entries for efficiency. - Added `normalize_uuid` function to standardize UUIDs in HTML representations for consistent testing. - Modified the `test_display_config_in_init` to use a custom display configuration and updated assertions to compare normalized HTML outputs. - Enhanced readability of assertions in `test_display_config_affects_repr` by formatting conditions.
1 parent ad83fc5 commit fb90fbc

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

python/tests/test_dataframe.py

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17+
import dis
1718
import os
1819
import re
1920
from typing import Any
@@ -54,14 +55,22 @@ def df():
5455

5556
@pytest.fixture
5657
def data():
57-
return [{"a": 1, "b": "x" * 50, "c": 3}] * 100
58+
return [{"a": 1, "b": "x" * 50, "c": 3}] * 10
5859

5960

6061
@pytest.fixture
6162
def span_expandable_class():
6263
return '<span class="expandable" id="'
6364

6465

66+
def normalize_uuid(html):
67+
return re.sub(
68+
r"[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}",
69+
"STATIC_UUID",
70+
html,
71+
)
72+
73+
6574
def test_display_config():
6675
# Test display_config initialization
6776
config = DataframeDisplayConfig(
@@ -133,9 +142,15 @@ def test_session_with_display_config(data, span_expandable_class):
133142

134143

135144
def test_display_config_in_init(data):
136-
# Test default display config directly in SessionContext constructor
145+
# Test display config directly in SessionContext constructor
146+
display_config = DataframeDisplayConfig(
147+
max_table_bytes=1024,
148+
min_table_rows=5,
149+
max_cell_length=10,
150+
max_table_rows_in_repr=3,
151+
)
137152

138-
ctx = SessionContext()
153+
ctx = SessionContext(display_config=display_config)
139154
df1 = ctx.from_pylist(data)
140155
html_repr1 = df1._repr_html_()
141156

@@ -150,7 +165,7 @@ def test_display_config_in_init(data):
150165
html_repr2 = df2._repr_html_()
151166

152167
# Both methods should result in equivalent display configuration
153-
assert html_repr1 != html_repr2
168+
assert normalize_uuid(html_repr1) == normalize_uuid(html_repr2)
154169

155170

156171
@pytest.fixture
@@ -1380,7 +1395,8 @@ def test_display_config_affects_repr(data):
13801395
# The representation should show truncated data (3 rows as specified)
13811396
assert (
13821397
# 5 = 1 header row + 3 separator line + 1 truncation message
1383-
repr_str.count("\n") <= max_table_rows_in_repr + 5
1398+
repr_str.count("\n")
1399+
<= max_table_rows_in_repr + 5
13841400
)
13851401
assert "Data truncated" in repr_str
13861402

@@ -1396,7 +1412,8 @@ def test_display_config_affects_repr(data):
13961412
# Should show all data without truncation message
13971413
assert (
13981414
# 4 = 1 header row + 3 separator lines
1399-
repr_str2.count("\n") == max_table_rows_in_repr + 4
1415+
repr_str2.count("\n")
1416+
== max_table_rows_in_repr + 4
14001417
) # All rows should be shown
14011418
assert "Data truncated" not in repr_str2
14021419

0 commit comments

Comments
 (0)