mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Change default of --fatal command line arg to terminate on error
This commit is contained in:
parent
ccb4e58882
commit
d8e4563a7f
4 changed files with 29 additions and 6 deletions
3
RELEASE.md
Normal file
3
RELEASE.md
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
Release type: major
|
||||
|
||||
Change default of `--fatal` command line switch to terminate on error.
|
||||
|
|
@ -438,12 +438,12 @@ def parse_arguments(argv=None):
|
|||
|
||||
parser.add_argument(
|
||||
"--fatal",
|
||||
metavar="errors|warnings",
|
||||
choices=("errors", "warnings"),
|
||||
default="",
|
||||
metavar="errors|warnings|ignore",
|
||||
choices=("errors", "warnings", "ignore"),
|
||||
default="errors",
|
||||
help=(
|
||||
"Exit the program with non-zero status if any "
|
||||
"errors/warnings encountered."
|
||||
"errors/warnings encountered, or ignore any errors."
|
||||
),
|
||||
)
|
||||
|
||||
|
|
@ -634,7 +634,7 @@ def main(argv=None):
|
|||
logs_dedup_min_level = getattr(logging, args.logs_dedup_min_level)
|
||||
init_logging(
|
||||
level=args.verbosity,
|
||||
fatal=args.fatal,
|
||||
fatal=args.fatal if args.fatal != "ignore" else "",
|
||||
name=__name__,
|
||||
handler=args.log_handler,
|
||||
logs_dedup_min_level=logs_dedup_min_level,
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ DEFAULT_LOG_HANDLER = RichHandler(console=console)
|
|||
|
||||
def init(
|
||||
level=None,
|
||||
fatal="",
|
||||
fatal="errors",
|
||||
handler=DEFAULT_LOG_HANDLER,
|
||||
name=None,
|
||||
logs_dedup_min_level=None,
|
||||
|
|
|
|||
20
pelican/tests/test_init.py
Normal file
20
pelican/tests/test_init.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import unittest
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from pelican import DEFAULT_LOG_HANDLER, main
|
||||
|
||||
|
||||
class TestLog(unittest.TestCase):
|
||||
@patch("pelican.get_instance")
|
||||
@patch("pelican.init_logging")
|
||||
def test_main_fatal_default(self, init_logging_mock, get_instance):
|
||||
get_instance.side_effect = lambda *args, **kwargs: (MagicMock(), MagicMock())
|
||||
main()
|
||||
init_logging_mock.assert_called_once_with(
|
||||
level=None,
|
||||
# default is "errors"
|
||||
fatal="errors",
|
||||
name="pelican",
|
||||
handler=DEFAULT_LOG_HANDLER,
|
||||
logs_dedup_min_level=30,
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue