1414UNMATERIALIZED_REGEX = re .compile (r".*\(No data to display: Dataframe not materialized\).*" )
1515MATERIALIZED_NO_ROWS_REGEX = re .compile (r".*\(No data to display: Materialized dataframe has no rows\).*" )
1616TD_STYLE = 'style="text-align:left; max-width:192px; max-height:64px; overflow:auto"'
17+ TH_STYLE = 'style="text-wrap: nowrap; max-width:192px; overflow:auto; text-align:left"'
1718
1819
1920def parse_str_table (
@@ -93,9 +94,9 @@ def test_empty_df_repr(make_df):
9394 assert parse_str_table (df .__repr__ (), expected_user_msg_regex = UNMATERIALIZED_REGEX ) == expected_data
9495 assert (
9596 df ._repr_html_ ()
96- == """<div>
97+ == f """<div>
9798<table class="dataframe">
98- <thead><tr><th style="text-wrap: nowrap; max-width:192px; overflow:auto" >A<br />Int64</th><th style="text-wrap: nowrap; max-width:192px; overflow:auto" >B<br />Utf8</th></tr></thead>
99+ <thead><tr><th { TH_STYLE } >A<br />Int64</th><th { TH_STYLE } >B<br />Utf8</th></tr></thead>
99100</table>
100101<small>(No data to display: Dataframe not materialized)</small>
101102</div>"""
@@ -115,9 +116,9 @@ def test_empty_df_repr(make_df):
115116 assert parse_str_table (df .__repr__ (), expected_user_msg_regex = MATERIALIZED_NO_ROWS_REGEX ) == expected_data
116117 assert (
117118 df ._repr_html_ ()
118- == """<div>
119+ == f """<div>
119120<table class="dataframe">
120- <thead><tr><th style="text-wrap: nowrap; max-width:192px; overflow:auto" >A<br />Int64</th><th style="text-wrap: nowrap; max-width:192px; overflow:auto" >B<br />Utf8</th></tr></thead>
121+ <thead><tr><th { TH_STYLE } >A<br />Int64</th><th { TH_STYLE } >B<br />Utf8</th></tr></thead>
121122<tbody>
122123</tbody>
123124</table>
@@ -134,9 +135,9 @@ def test_alias_repr(make_df):
134135 assert parse_str_table (df .__repr__ (), expected_user_msg_regex = UNMATERIALIZED_REGEX ) == expected_data
135136 assert (
136137 df ._repr_html_ ()
137- == """<div>
138+ == f """<div>
138139<table class="dataframe">
139- <thead><tr><th style="text-wrap: nowrap; max-width:192px; overflow:auto" >A2<br />Int64</th><th style="text-wrap: nowrap; max-width:192px; overflow:auto" >B<br />Utf8</th></tr></thead>
140+ <thead><tr><th { TH_STYLE } >A2<br />Int64</th><th { TH_STYLE } >B<br />Utf8</th></tr></thead>
140141</table>
141142<small>(No data to display: Dataframe not materialized)</small>
142143</div>"""
@@ -162,7 +163,7 @@ def test_alias_repr(make_df):
162163 df ._repr_html_ ()
163164 == f"""<div>
164165<table class="dataframe">
165- <thead><tr><th style="text-wrap: nowrap; max-width:192px; overflow:auto" >A2<br />Int64</th><th style="text-wrap: nowrap; max-width:192px; overflow:auto" >B<br />Utf8</th></tr></thead>
166+ <thead><tr><th { TH_STYLE } >A2<br />Int64</th><th { TH_STYLE } >B<br />Utf8</th></tr></thead>
166167<tbody>
167168<tr><td><div { TD_STYLE } >1</div></td><td><div { TD_STYLE } >a</div></td></tr>
168169<tr><td><div { TD_STYLE } >2</div></td><td><div { TD_STYLE } >b</div></td></tr>
@@ -189,15 +190,15 @@ def test_repr_with_unicode(make_df, data_source):
189190 }
190191
191192 string_array = ["🔥a" , "b🔥" , "🦁🔥" * 60 ] # we dont truncate for html
192- expected_html_unmaterialized = """<div>
193+ expected_html_unmaterialized = f """<div>
193194<table class="dataframe">
194- <thead><tr><th style="text-wrap: nowrap; max-width:192px; overflow:auto" >🔥<br />Int64</th><th style="text-wrap: nowrap; max-width:192px; overflow:auto" >🦁<br />Utf8</th></tr></thead>
195+ <thead><tr><th { TH_STYLE } >🔥<br />Int64</th><th { TH_STYLE } >🦁<br />Utf8</th></tr></thead>
195196</table>
196197<small>(No data to display: Dataframe not materialized)</small>
197198</div>"""
198199 expected_html_materialized = f"""<div>
199200<table class="dataframe">
200- <thead><tr><th style="text-wrap: nowrap; max-width:192px; overflow:auto" >🔥<br />Int64</th><th style="text-wrap: nowrap; max-width:192px; overflow:auto" >🦁<br />Utf8</th></tr></thead>
201+ <thead><tr><th { TH_STYLE } >🔥<br />Int64</th><th { TH_STYLE } >🦁<br />Utf8</th></tr></thead>
201202<tbody>
202203<tr><td><div { TD_STYLE } >1</div></td><td><div { TD_STYLE } >{ string_array [0 ]} </div></td></tr>
203204<tr><td><div { TD_STYLE } >2</div></td><td><div { TD_STYLE } >{ string_array [1 ]} </div></td></tr>
0 commit comments