added support for --no-logging argument to avoid leaking loggers in tests

This commit is contained in:
Lex Berezhny 2019-12-31 17:21:08 -05:00
parent 87c7ce588e
commit b49275fe6b
2 changed files with 7 additions and 2 deletions

View file

@ -187,6 +187,10 @@ def get_argument_parser():
'--quiet', dest='quiet', action="store_true", '--quiet', dest='quiet', action="store_true",
help='Disable all console output.' help='Disable all console output.'
) )
start.add_argument(
'--no-logging', dest='no_logging', action="store_true",
help='Disable all logging of any kind.'
)
start.add_argument( start.add_argument(
'--verbose', nargs="*", '--verbose', nargs="*",
help=('Enable debug output for lbry logger and event loop. Optionally specify loggers for which debug output ' help=('Enable debug output for lbry logger and event loop. Optionally specify loggers for which debug output '
@ -261,7 +265,8 @@ def run_daemon(args: argparse.Namespace, conf: Config):
loop = asyncio.get_event_loop() loop = asyncio.get_event_loop()
if args.verbose is not None: if args.verbose is not None:
loop.set_debug(True) loop.set_debug(True)
setup_logging(logging.getLogger(), args, conf) if not args.no_logging:
setup_logging(logging.getLogger(), args, conf)
daemon = Daemon(conf) daemon = Daemon(conf)
def __exit(): def __exit():

View file

@ -200,7 +200,7 @@ class CLITest(AsyncioTestCase):
raise KeyboardInterrupt raise KeyboardInterrupt
mock_daemon_start.side_effect = side_effect mock_daemon_start.side_effect = side_effect
self.shell(["start"]) self.shell(["start", "--no-logging"])
mock_daemon_start.assert_called_once() mock_daemon_start.assert_called_once()