Skip to content

Commit

Permalink
Tests related to loading settings from a given file
Browse files Browse the repository at this point in the history
  • Loading branch information
lbiaggi committed Mar 14, 2024
1 parent 379e445 commit b99d87f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
11 changes: 10 additions & 1 deletion doorstop/cli/tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from doorstop import settings
from doorstop.cli import main
from doorstop.cli.tests import SettingsTestCase
from doorstop.cli.tests import FILES, SettingsTestCase


class TestMain(SettingsTestCase):
Expand Down Expand Up @@ -84,3 +84,12 @@ def test_main(self):
spec.loader.exec_module(runpy)
# Assert
self.assertIsNotNone(runpy)

@patch("doorstop.cli.commands.run", Mock())
def test_run_modified_settings_through_file(self):
"""Verify --settings has override settings."""
main.main(args=["--settings", f"{FILES}/settings_modified.py"])
self.assertEqual(settings.MAX_LINE_LENGTH, 20)
# rollback to the original value to not impact an item test
settings.MAX_LINE_LENGTH = 79
self.assertEqual(settings.MAX_LINE_LENGTH, 79)
9 changes: 9 additions & 0 deletions doorstop/core/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@ def set_items(self, items):
self._items = items


class MockSimpleDocumentExtensions(MockSimpleDocument):
"""Mock Document class that enable extensions."""

def __init__(self, **kwargs):
super().__init__()
for k, v in kwargs.items():
self.extensions[k] = v


class MockDocumentSkip(MockDocument): # pylint: disable=W0223,R0902
"""Mock Document class that is always skipped in tree placement."""

Expand Down

0 comments on commit b99d87f

Please sign in to comment.