Skip to content
Merged
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
10 changes: 5 additions & 5 deletions tests/test_generated_binding_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ def extract(tmp_path: Path, source: str, helper: str | None = None,
addon: bool = False) -> tuple:
workload = tmp_path / "workload"
workload.mkdir()
(workload / "app.py").write_text(source)
(workload / "app.py").write_text(source, encoding="utf-8")
if helper is not None:
(workload / "helper.py").write_text(helper)
(workload / "helper.py").write_text(helper, encoding="utf-8")
packages = (package(),)
if addon:
packages += (package("addon_binding", "urn:example:addon", False),)
Expand Down Expand Up @@ -171,7 +171,7 @@ def test_recognized_declarations_fail_with_source_and_coordinate(
with pytest.raises(RuntimeConditionsError) as failure:
extract(tmp_path, source)
assert message in str(failure.value)
assert "/app.py:" in str(failure.value)
assert "/app.py:" in str(failure.value).replace("\\", "/")
assert DECLARATION in str(failure.value) or SCHEMA in str(failure.value)


Expand Down Expand Up @@ -212,7 +212,7 @@ def test_conditional_local_reexport_does_not_hide_declaration(tmp_path: Path) ->
"if enabled:\n from helper import declare\ndeclare()\n",
"from example_binding import service as declare\n",
)
assert "/app.py:3:1" in str(failure.value)
assert "/app.py:3:1" in str(failure.value).replace("\\", "/")


def test_local_star_import_fails_closed(tmp_path: Path) -> None:
Expand All @@ -233,4 +233,4 @@ def test_cross_module_cycle_is_source_located(tmp_path: Path) -> None:
(workload / "helper.py").write_text("from app import region\n")
with pytest.raises(RuntimeConditionsError, match="cyclic module reference|cyclic static reference") as failure:
GeneratedBindingExtractor(VerifiedBindingSet((package(),), (package(),))).extract(workload)
assert "/app.py:3:" in str(failure.value)
assert "/app.py:3:" in str(failure.value).replace("\\", "/")
4 changes: 2 additions & 2 deletions tests/test_installed_binding_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ def test_semantic_errors_are_source_located(condition: dict[str, object], messag
candidate = semantic_candidate(condition, "https://example.test/base:1.0.0")
with pytest.raises(RuntimeConditionsError) as failure:
GeneratedProfileValidator(bindings).build((candidate,), "sample", "example/sample", "1")
assert "/workload/app.py:3:1: conditions[0]" in str(failure.value)
assert "/workload/app.py:3:1: conditions[0]" in str(failure.value).replace("\\", "/")
assert message in str(failure.value)


Expand All @@ -812,7 +812,7 @@ def test_semantic_validator_checks_complete_core_profile_and_duplicate_names() -
GeneratedProfileValidator(bindings).build((candidate,), "", "example/sample", "1")
with pytest.raises(RuntimeConditionsError, match="duplicate Condition name") as failure:
GeneratedProfileValidator(bindings).build((candidate, candidate), "sample", "example/sample", "1")
assert "/workload/app.py:3:1: conditions[1]/name" in str(failure.value)
assert "/workload/app.py:3:1: conditions[1]/name" in str(failure.value).replace("\\", "/")


def test_semantic_validator_checks_scoped_values_and_rejects_external_schema_refs() -> None:
Expand Down