diff --git a/sync_pre_commit_deps.py b/sync_pre_commit_deps.py index fdc28ec..9897087 100644 --- a/sync_pre_commit_deps.py +++ b/sync_pre_commit_deps.py @@ -47,7 +47,7 @@ def main(argv: Sequence[str] | None = None) -> int: yaml.preserve_quotes = True yaml.indent(yaml_mapping, yaml_sequence, yaml_offset) - with open(filename) as f: + with open(filename, encoding='utf-8') as f: loaded = yaml.load(f) # TODO - validate schema? diff --git a/tests/sync_pre_commit_deps_test.py b/tests/sync_pre_commit_deps_test.py index 8f5517a..c12c13d 100644 --- a/tests/sync_pre_commit_deps_test.py +++ b/tests/sync_pre_commit_deps_test.py @@ -35,15 +35,25 @@ ' - mypy==0.123\n', id='local hook shadows supported lib', ), + pytest.param( + 'repos:\n' + '- repo: https://github.com/psf/black\n' + ' rev: 23.3.0\n' + ' hooks:\n' + ' - name: \N{SNOWMAN} black\n' + ' id: black\n', + id='unicode no-op', + ), ), ) def test_main_noop(tmpdir, s): cfg = tmpdir.join('.pre-commit-config.yaml') - cfg.write(s) + cfg.write_binary(s.encode()) assert not main((str(cfg),)) - assert cfg.read() == s + with open(cfg, encoding='utf-8') as f: + assert f.read() == s def test_main_writes_all(tmpdir):