Skip to content

Commit 718aee9

Browse files
Use UTF-8 when reading Bedrock test fixtures (#3530)
## Summary - Read Bedrock JSON/JSONL fixture files with `encoding="utf-8"` instead of the platform default encoding. - Keep the opt-in Bedrock live env-file reader deterministic across developer machines. ## Problem These test fixtures and optional live-test env files are text inputs with repo-controlled formats, but `Path.read_text()` defaults to the host locale. On Windows or other non-UTF-8 locales, that can make the Bedrock tests less portable than they need to be. ## Before / After Before: Bedrock fixture loading depended on the platform default text encoding. After: the fixture and env-file readers explicitly decode as UTF-8. ## Verification - `python -m py_compile tests/lib/test_bedrock_auth_conformance.py tests/lib/bedrock_live.py` - `uv run --with pytest --with pytest-asyncio --with pytest-xdist --with jsonschema --with respx --with botocore python -m pytest -q tests/lib/test_bedrock_auth_conformance.py` (`20 passed`) Co-authored-by: Marcus Wood <marcuswood@openai.com>
1 parent 43045fc commit 718aee9

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

‎tests/lib/bedrock_live.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def _load_env_file() -> None:
4343
raise RuntimeError(f"BEDROCK_LIVE_ENV_FILE does not exist: {path}")
4444
return
4545

46-
for line_number, raw_line in enumerate(path.read_text().splitlines(), start=1):
46+
for line_number, raw_line in enumerate(path.read_text(encoding="utf-8").splitlines(), start=1):
4747
line = raw_line.strip()
4848
if not line or line.startswith("#"):
4949
continue

‎tests/lib/test_bedrock_auth_conformance.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
FIXTURE_PATH = Path(__file__).parents[1] / "fixtures" / "bedrock_auth" / "v1" / "cases.json"
2323
SCHEMA_PATH = FIXTURE_PATH.with_name("schema.json")
2424
SHARED_SIGV4_FIXTURE_PATH = Path(__file__).parents[1] / "fixtures" / "bedrock" / "v1" / "sigv4.json"
25-
FIXTURES = cast(dict[str, Any], json.loads(FIXTURE_PATH.read_text()))
26-
SCHEMA = cast(dict[str, Any], json.loads(SCHEMA_PATH.read_text()))
27-
SHARED_SIGV4_FIXTURE = cast(dict[str, Any], json.loads(SHARED_SIGV4_FIXTURE_PATH.read_text()))
25+
FIXTURES = cast(dict[str, Any], json.loads(FIXTURE_PATH.read_text(encoding="utf-8")))
26+
SCHEMA = cast(dict[str, Any], json.loads(SCHEMA_PATH.read_text(encoding="utf-8")))
27+
SHARED_SIGV4_FIXTURE = cast(dict[str, Any], json.loads(SHARED_SIGV4_FIXTURE_PATH.read_text(encoding="utf-8")))
2828

2929
# This is deliberately specific to the small, checked-in v1 fixture contract.
3030
_REQUIRED_CASE_FIELDS: dict[str, dict[str, list[str]]] = {

0 commit comments

Comments
 (0)