Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/python/plotly/plotly/io/_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,8 @@ def write_html(

# Write HTML string
if path is not None:
path.write_text(html_str)
# To use a different file encoding, pass a file descriptor
path.write_text(html_str, "utf-8")
else:
file.write(html_str)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def test_write_html():
mock_pathlib_path = Mock(spec=Path)
pio.write_html(fig, mock_pathlib_path)
mock_pathlib_path.write_text.assert_called_once()
(pl_html,) = mock_pathlib_path.write_text.call_args[0]
pl_html = mock_pathlib_path.write_text.call_args[0][0]
assert replace_div_id(html) == replace_div_id(pl_html)

# Test pio.write_html with a mock file descriptor
Expand Down