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
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import stat
from typing import Generic, List, Type, TypeVar

from ..._utils import secure_open
from ..._osname import OSName
from ._configuration import AdaptorConfiguration, Configuration

Expand Down Expand Up @@ -96,7 +95,7 @@ def _ensure_config_file(filepath: str, *, create: bool = False) -> bool:
_logger.info(f"Creating empty configuration at {filepath}")
try:
os.makedirs(os.path.dirname(filepath), mode=stat.S_IRWXU, exist_ok=True)
with secure_open(filepath, open_mode="w", encoding="utf-8") as f:
with open(filepath, mode="w", encoding="utf-8") as f:
json.dump({}, f)
except OSError as e:
_logger.warning(f"Could not write empty configuration to {filepath}: {e}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def test_create(
mock_exists.return_value = False

open_mock: MagicMock
with patch.object(configuration_manager, "secure_open", mock_open()) as open_mock:
with patch("builtins.open", mock_open()) as open_mock:
if not created:
open_mock.side_effect = OSError()

Expand All @@ -119,7 +119,7 @@ def test_create(
# THEN
assert result == created
mock_exists.assert_called_once_with(path)
open_mock.assert_called_once_with(path, open_mode="w", encoding="utf-8")
open_mock.assert_called_once_with(path, mode="w", encoding="utf-8")
assert f'Configuration file at "{path}" does not exist.' in caplog.text
assert f"Creating empty configuration at {path}" in caplog.text
if created:
Expand Down
Loading