@@ -1493,8 +1493,8 @@ def add_with_parameter(df_internal, value: Any) -> DataFrame:
14931493 assert result ["new_col" ] == [3 for _i in range (3 )]
14941494
14951495
1496- def test_dataframe_repr_html (df ) -> None :
1497- """Test that DataFrame._repr_html_ produces expected HTML output."""
1496+ def test_dataframe_repr_html_structure (df ) -> None :
1497+ """Test that DataFrame._repr_html_ produces expected HTML output structure ."""
14981498
14991499 output = df ._repr_html_ ()
15001500
@@ -1514,9 +1514,32 @@ def test_dataframe_repr_html(df) -> None:
15141514 assert len (re .findall (body_pattern , output , re .DOTALL )) == 1
15151515
15161516
1517- def test_dataframe_repr_html (df ):
1518- """Test that DataFrame._repr_html_ produces expected HTML output."""
1519- import re
1517+ def test_dataframe_repr_html_values (df ):
1518+ """Test that DataFrame._repr_html_ contains the expected data values."""
1519+ html = df ._repr_html_ ()
1520+ assert html is not None
1521+
1522+ # Create a more flexible pattern that handles values being wrapped in spans
1523+ # This pattern will match the sequence of values 1,4,8,2,5,5,3,6,8 regardless of formatting
1524+ pattern = re .compile (
1525+ r"<td[^>]*?>(?:<span[^>]*?>)?1(?:</span>)?</td>.*?"
1526+ + r"<td[^>]*?>(?:<span[^>]*?>)?4(?:</span>)?</td>.*?"
1527+ + r"<td[^>]*?>(?:<span[^>]*?>)?8(?:</span>)?</td>.*?"
1528+ + r"<td[^>]*?>(?:<span[^>]*?>)?2(?:</span>)?</td>.*?"
1529+ + r"<td[^>]*?>(?:<span[^>]*?>)?5(?:</span>)?</td>.*?"
1530+ + r"<td[^>]*?>(?:<span[^>]*?>)?5(?:</span>)?</td>.*?"
1531+ + r"<td[^>]*?>(?:<span[^>]*?>)?3(?:</span>)?</td>.*?"
1532+ + r"<td[^>]*?>(?:<span[^>]*?>)?6(?:</span>)?</td>.*?"
1533+ + r"<td[^>]*?>(?:<span[^>]*?>)?8(?:</span>)?</td>" ,
1534+ re .DOTALL ,
1535+ )
1536+
1537+ # Print debug info if the test fails
1538+ matches = re .findall (pattern , html )
1539+ if not matches :
1540+ print (f"HTML output snippet: { html [:500 ]} ..." )
1541+
1542+ assert len (matches ) > 0 , "Expected pattern of values not found in HTML output"
15201543
15211544 html = df ._repr_html_ ()
15221545 assert html is not None
0 commit comments