Skip to content

Commit 03d44db

Browse files
committed
Ensure UTF-8 when reading/writing files in tests
1 parent 35eba8f commit 03d44db

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

tests/test_compile_to_code.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def test_compile_to_code_custom_format_with_refs(tmp_path, monkeypatch):
116116
formats = {'my-format': str.isidentifier}
117117
code = compile_to_code(schema, formats=formats)
118118

119-
(tmp_path / "schema_4.py").write_text(code)
119+
(tmp_path / "schema_4.py").write_text(code, encoding="utf-8")
120120
with monkeypatch.context() as m:
121121
m.syspath_prepend(tmp_path)
122122
from schema_4 import validate

tests/test_examples.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@
3030
def test_validate(example_group):
3131
example_dir = EXAMPLES / example_group
3232
schema = next(example_dir.glob("*.schema.json"))
33-
validator = compile(json.loads(schema.read_text()))
33+
validator = compile(json.loads(schema.read_text(encoding="utf-8")))
3434
examples = (
35-
(e, e.with_suffix(".error"), json.loads(e.read_text()))
35+
(e, e.with_suffix(".error"), json.loads(e.read_text(encoding="utf-8")))
3636
for e in example_dir.glob("*.json")
3737
if not str(e).endswith(".schema.json")
3838
)
3939
for example_file, err_file, example in examples:
4040
if err_file.exists():
4141
with pytest.raises(JsonSchemaException) as exc_info:
4242
validator(example)
43-
assert err_file.read_text().strip() in str(exc_info.value).strip()
43+
assert err_file.read_text(encoding="utf-8").strip() in str(exc_info.value).strip()
4444
else:
4545
validator(example) # valid

0 commit comments

Comments
 (0)