Skip to content
Open
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 scripts/check_cassettes.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def _has_module_vcr_marker(tree: ast.Module) -> bool:
def _collect_vcr_tests_from_file(path: Path) -> set[str]:
"""Parse a Python test file and return cassette names for VCR-marked tests."""
try:
tree = ast.parse(path.read_text())
tree = ast.parse(path.read_text(encoding='utf-8'))
except SyntaxError:
return set()

Expand Down
21 changes: 21 additions & 0 deletions tests/test_check_cassettes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from pathlib import Path

from scripts.check_cassettes import _collect_vcr_tests_from_file


def test_collect_vcr_tests_reads_utf8_source(tmp_path: Path) -> None:
test_file = tmp_path / 'test_unicode_source.py'
test_file.write_text(
"""\
import pytest


@pytest.mark.vcr
def test_unicode_source_comment():
message = 'Olá, 世界'
assert message
""",
encoding='utf-8',
)

assert _collect_vcr_tests_from_file(test_file) == {'test_unicode_source_comment'}
Loading