diff --git a/pandas/tests/io/formats/data/html/gh13828_expected_output.html b/pandas/tests/io/formats/data/html/gh13828_expected_output.html
new file mode 100644
index 0000000000000..690d638c31d5b
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/gh13828_expected_output.html
@@ -0,0 +1,21 @@
+
+
+
+ |
+ Group |
+ Data |
+
+
+
+
+ 0 |
+ A |
+ 1.22 |
+
+
+ 1 |
+ A |
+ {na_rep} |
+
+
+
diff --git a/pandas/tests/io/formats/data/html/gh40024_expected_output.html b/pandas/tests/io/formats/data/html/gh40024_expected_output.html
new file mode 100644
index 0000000000000..0877c29525d2c
--- /dev/null
+++ b/pandas/tests/io/formats/data/html/gh40024_expected_output.html
@@ -0,0 +1,18 @@
+
+
+
+ |
+ x |
+
+
+
+
+ 0 |
+ 1,000 |
+
+
+ 1 |
+ test |
+
+
+
diff --git a/pandas/tests/io/formats/test_to_html.py b/pandas/tests/io/formats/test_to_html.py
index ec2f109900f3a..a61e77bec9828 100644
--- a/pandas/tests/io/formats/test_to_html.py
+++ b/pandas/tests/io/formats/test_to_html.py
@@ -851,7 +851,7 @@ def test_to_html_multilevel(multiindex_year_month_day_dataframe_random_data):
@pytest.mark.parametrize("na_rep", ["NaN", "Ted"])
-def test_to_html_na_rep_and_float_format(na_rep):
+def test_to_html_na_rep_and_float_format(na_rep, datapath):
# https://github.com/pandas-dev/pandas/issues/13828
df = DataFrame(
[
@@ -861,51 +861,14 @@ def test_to_html_na_rep_and_float_format(na_rep):
columns=["Group", "Data"],
)
result = df.to_html(na_rep=na_rep, float_format="{:.2f}".format)
- expected = f"""
-
-
- |
- Group |
- Data |
-
-
-
-
- 0 |
- A |
- 1.22 |
-
-
- 1 |
- A |
- {na_rep} |
-
-
-
"""
+ expected = expected_html(datapath, "gh13828_expected_output")
+ expected = expected.format(na_rep=na_rep)
assert result == expected
-def test_to_html_float_format_object_col():
+def test_to_html_float_format_object_col(datapath):
# GH#40024
df = DataFrame(data={"x": [1000.0, "test"]})
result = df.to_html(float_format=lambda x: f"{x:,.0f}")
- expected = """
-
-
- |
- x |
-
-
-
-
- 0 |
- 1,000 |
-
-
- 1 |
- test |
-
-
-
"""
-
+ expected = expected_html(datapath, "gh40024_expected_output")
assert result == expected