Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


from pathlib import Path
from unittest.mock import patch

import pytest
from smithy_aws_core.config import load_config
Expand All @@ -26,12 +27,13 @@ async def test_load_config_with_missing_files(self, tmp_path: Path):
async def test_permission_denied_returns_empty(self, tmp_path: Path):
restricted_file = tmp_path / "restricted_config"
restricted_file.write_text("[profile default]\nregion = us-east-1\n")
restricted_file.chmod(0o000)
try:
# Patch read_text to raise PermissionError rather than relying on
# chmod(0o000), which is bypassed when tests run as root (e.g. in CI).
with patch.object(
Path, "read_text", side_effect=PermissionError("Permission denied")
):
result = await parse_config_file(str(restricted_file))
assert result == {}
finally:
restricted_file.chmod(0o644)
assert result == {}


class TestEncodingErrors:
Expand Down
Loading