Skip to content

Commit

Permalink
use a dummy settings class instead of mocking.
Browse files Browse the repository at this point in the history
  • Loading branch information
perrygoy committed Aug 1, 2024
1 parent c9e54a5 commit fae9b8b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import os
from unittest import mock

from pydantic_settings import BaseSettings

from screenpy import settings as screenpy_settings
from screenpy.configuration import PyprojectTomlConfig, ScreenPySettings
from screenpy.narration.stdout_adapter import settings as stdout_adapter_settings
Expand Down Expand Up @@ -44,6 +46,9 @@ def test__parse_pyproject_toml_file_exists(self, MockedPath: mock.Mock) -> None:

@mock.patch("screenpy.configuration.Path", autospec=True)
def test__parse_pyproject_toml_no_tool_path(self, MockedPath: mock.Mock) -> None:
class DummySettings(BaseSettings):
"""Settings class without a _tool_path set."""

MockedPath.cwd.return_value.__truediv__.return_value = MockedPath
MockedPath.is_file.return_value = True
test_data = (
Expand All @@ -54,10 +59,8 @@ def test__parse_pyproject_toml_no_tool_path(self, MockedPath: mock.Mock) -> None
MockedPath.open.side_effect = mock_open.side_effect
MockedPath.open.return_value = mock_open.return_value

with mock.patch("screenpy.configuration.hasattr") as mockhasattr:
mockhasattr.return_value = False
pyproject_config = PyprojectTomlConfig(ScreenPySettings)
pyproject_config._parse_pyproject_toml()
pyproject_config = PyprojectTomlConfig(DummySettings)
pyproject_config._parse_pyproject_toml()

assert pyproject_config.toml_config == {}

Expand Down

0 comments on commit fae9b8b

Please sign in to comment.