diff --git a/tests/test_cmark_spec/get_cmark_spec.py b/tests/test_cmark_spec/get_cmark_spec.py index 2883835e..2ced0285 100644 --- a/tests/test_cmark_spec/get_cmark_spec.py +++ b/tests/test_cmark_spec/get_cmark_spec.py @@ -72,9 +72,12 @@ def _json_to_fixture(data: list[dict[str, Any]]) -> str: print(f"Downloading CommonMark spec from {url}") response = requests.get(url) response.raise_for_status() - if not output_path.exists() or output_path.read_text() != response.text: + if ( + not output_path.exists() + or output_path.read_text(encoding="utf-8") != response.text + ): changed = True - with output_path.open("w") as f: + with output_path.open("w", encoding="utf-8") as f: f.write(response.text) print(f"Updated to {output_path}") else: @@ -85,9 +88,9 @@ def _json_to_fixture(data: list[dict[str, Any]]) -> str: response.raise_for_status() data = response.json() text = _json_to_fixture(data) - if not test_fixture.exists() or test_fixture.read_text() != text: + if not test_fixture.exists() or test_fixture.read_text(encoding="utf-8") != text: changed = True - with test_fixture.open("w") as f: + with test_fixture.open("w", encoding="utf-8") as f: f.write(text) print(f"Also updated to {test_fixture}") else: diff --git a/tests/test_cmark_spec/test_spec.py b/tests/test_cmark_spec/test_spec.py index e5199477..b4becc25 100644 --- a/tests/test_cmark_spec/test_spec.py +++ b/tests/test_cmark_spec/test_spec.py @@ -15,10 +15,12 @@ def test_file(file_regression): md = MarkdownIt("commonmark") - file_regression.check(md.render(SPEC_INPUT.read_text()), extension=".html") + file_regression.check( + md.render(SPEC_INPUT.read_text(encoding="utf-8")), extension=".html" + ) -@pytest.mark.parametrize("entry", json.loads(TESTS_INPUT.read_text())) +@pytest.mark.parametrize("entry", json.loads(TESTS_INPUT.read_text(encoding="utf-8"))) def test_spec(entry): md = MarkdownIt("commonmark") output = md.render(entry["markdown"])