Skip to content

Commit 18877d9

Browse files
committed
exact string match assertion for large html
1 parent 60ec007 commit 18877d9

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

pandas/tests/io/formats/test_format.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1876,7 +1876,7 @@ def test_repr_html_series(self):
18761876
small = pd.Series(data, name="test series")
18771877
sm_html = small._repr_html_()
18781878

1879-
html = (
1879+
true_sm_html = (
18801880
"<div>\n<style scoped>\n .dataframe tbody tr th:only-of-type {\n"
18811881
" vertical-align: middle;\n }\n\n .dataframe tbody tr th"
18821882
" {\n vertical-align: top;\n }\n\n .dataframe thead th {\n"
@@ -1891,14 +1891,28 @@ def test_repr_html_series(self):
18911891
"</div>"
18921892
)
18931893

1894-
assert sm_html == html
1894+
assert sm_html == true_sm_html
18951895

18961896
large = small.repeat(1000)
18971897
large.name = None
18981898
lg_html = large._repr_html_()
18991899

1900-
assert "<td>...</td>" in lg_html
1901-
assert "<p>Name: <b>" not in lg_html
1900+
true_lg_html = (
1901+
"<div>\n<style scoped>\n .dataframe tbody tr th:only-of-type {\n"
1902+
" vertical-align: middle;\n }\n\n .dataframe tbody tr th {\n"
1903+
" vertical-align: top;\n }\n\n .dataframe thead th {\n"
1904+
' text-align: right;\n }\n</style>\n<table border="1" '
1905+
'class="dataframe">\n <tbody>\n <tr>\n <th>0</th>\n <td>1</td>'
1906+
"\n </tr>\n <tr>\n <th>0</th>\n <td>1</td>\n </tr>\n "
1907+
"<tr>\n <th>0</th>\n <td>1</td>\n </tr>\n <tr>\n "
1908+
"<th>...</th>\n <td>...</td>\n </tr>\n <tr>\n <th>5</th>\n"
1909+
" <td>NaN</td>\n </tr>\n <tr>\n <th>5</th>\n "
1910+
"<td>NaN</td>\n </tr>\n <tr>\n <th>5</th>\n <td>NaN</td>\n"
1911+
" </tr>\n </tbody>\n</table>\n<p>Length: 6000, dtype: <tt>object</tt>"
1912+
"</p>\n</div>"
1913+
)
1914+
1915+
assert lg_html == true_lg_html
19021916

19031917
tm.reset_display_options()
19041918

0 commit comments

Comments
 (0)