Skip to content

Commit

Permalink
🐛 fix(config): dump default config in UTF-8
Browse files Browse the repository at this point in the history
For Windows compatibility.
  • Loading branch information
welpo committed Nov 21, 2024
1 parent 00987ce commit 8f6647b
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion shuku/config.py
Original file line number Diff line number Diff line change
@@ -411,7 +411,7 @@ def dump_default_config() -> None:
logging.warning("Configuration creation cancelled.")
sys.exit(0)
Path(file_path).parent.mkdir(parents=True, exist_ok=True)
with open(file_path, "w") as f:
with open(file_path, "w", encoding="utf-8") as f:
f.write(content)
logging.success(f"Configuration file created: {file_path}") # type: ignore
except OSError as e:
6 changes: 4 additions & 2 deletions tests/test_config.py
Original file line number Diff line number Diff line change
@@ -371,7 +371,7 @@ def test_dump_default_config_unicode_path(
patch("builtins.open", mock_open()) as mock_file,
):
dump_default_config()
mock_file.assert_called_once_with(unicode_path, "w")
mock_file.assert_called_once_with(unicode_path, "w", encoding="utf-8")


def test_dump_default_config_disk_full_error(
@@ -438,7 +438,9 @@ def test_dump_default_config_existing_file_overwrite(
["overwrite", "cancel"],
default="Cancel",
)
mock_file.assert_called_once_with(mock_default_config_path, "w")
mock_file.assert_called_once_with(
mock_default_config_path, "w", encoding="utf-8"
)
mock_file().write.assert_called_once_with(mock_generate_content)


0 comments on commit 8f6647b

Please sign in to comment.