Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config: set encoding to UTF8 in ConfigObj (bug 1885707) #1658

Merged
merged 1 commit into from
Apr 4, 2024
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
2 changes: 1 addition & 1 deletion mozregression/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def write_config(conf_path):
if not os.path.isdir(conf_dir):
os.makedirs(conf_dir)

config = ConfigObj(conf_path)
config = ConfigObj(conf_path, encoding="UTF8")
if not config.initial_comment:
config.initial_comment = CONF_HELP.splitlines()

Expand Down
10 changes: 8 additions & 2 deletions tests/unit/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ def tmp():
True,
{"persist": "", "persist-size-limit": "0.0", "bits": "32"},
),
# persist directory with some ascii characters
("mac", 64, ["abcdefg", ""], False, {"persist": "abcdefg", "persist-size-limit": "20.0"}),
# persist directory with some unicode characters
("mac", 64, ["åbcdefg", ""], False, {"persist": "åbcdefg", "persist-size-limit": "20.0"}),
],
)
def test_write_config(tmp, mocker, os_, bits, inputs, conf_dir_exists, results):
Expand All @@ -56,9 +60,11 @@ def test_write_config(tmp, mocker, os_, bits, inputs, conf_dir_exists, results):
if not conf_dir_exists:
mozfile.remove(conf_path)
write_config(conf_path)
if "persist" in results and results["persist"] is None:
# default persist is base on the directory of the conf file
if "persist" in results and results["persist"]:
results["persist"] = os.path.realpath(results["persist"])
elif "persist" in results and results["persist"] is None:
results["persist"] = os.path.join(tmp, "persist")

conf = get_config(conf_path)
for key in results:
assert conf[key] == results[key]
Expand Down
Loading