Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion src/towncrier/_settings/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def load_config_from_options(
config = load_config_from_file(os.path.dirname(config_path), config_path)

if config is None:
raise ConfigError(f"No configuration file found.\nLooked in: {base_directory}")
sys.exit(f"No configuration file found.\nLooked in: {base_directory}")

return base_directory, config

Expand Down
1 change: 1 addition & 0 deletions src/towncrier/newsfragments/501.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Don't raise an exception with ``towncrier check`` on missing configuration.
17 changes: 17 additions & 0 deletions src/towncrier/test/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@

from textwrap import dedent

from click.testing import CliRunner
from twisted.trial.unittest import TestCase

from .._settings import ConfigError, load_config
from .._shell import cli


class TomlSettingsTests(TestCase):
Expand Down Expand Up @@ -153,6 +155,21 @@ def test_towncrier_toml_preferred(self):
config = load_config(temp)
self.assertEqual(config.package, "a")

def test_load_no_config(self):
"""
Check that no exception is raised if no config is found in the base directory.
"""
temp = self.mktemp()
os.makedirs(temp)

runner = CliRunner()
result = runner.invoke(cli, ["--dir", temp])
self.assertEqual(
result.output,
f"No configuration file found.\nLooked in: {os.path.abspath(temp)}\n",
)
self.assertEqual(result.exit_code, 1)

def test_missing_template(self):
"""
Towncrier will raise an exception saying when it can't find a template.
Expand Down