Commit eaa41668 authored by anarcat's avatar anarcat
Browse files

Merge branch 'feature/quieter-test-output' into '2.x'

Quiet logging in test output when not in debug mode

See merge request !22
parents 9f78da7e 78c56043
......@@ -73,6 +73,15 @@ class CliBaseTest(unittest.TestCase):
self.argv = sys.argv
sys.argv = [ 'monkeysign', '--no-mail' ]
if '--debug' not in self.argv:
# Save the logging handlers on the root logger to a variable
# and replace them with a NullHandler (the null handler
# prevents logging calls from trying to add a stream handler
# back). This stops output from the tested functions from
# printing to the console and cluttering things up.
self.logging_handlers = logging.getLogger().handlers
logging.getLogger().handlers = [logging.NullHandler()]
def execute(self):
'''execute the monkeysign script directly
......@@ -120,6 +129,10 @@ class CliBaseTest(unittest.TestCase):
def tearDown(self):
sys.argv = self.argv
if '--debug' not in self.argv:
# Restore the logging handlers we removed in the setup function
logging.getLogger().handlers = self.logging_handlers
@unittest.skipUnless(Mock, 'mock library missing')
class CliTestCase(CliBaseTest):
......@@ -475,7 +475,7 @@ configuration files are parsed by default: %s"""
# cargo-culted from caff, thanks guilhem!
src = self.keyring.get_agent_socket()
dst = self.tmpkeyring.get_agent_socket()'installing symlinks for sockets from %s to %s'), (src, dst))'installing symlinks for sockets from %s to %s'), src, dst)
except OSError as e:
......@@ -775,7 +775,7 @@ expects an EmailFactory email, but will not mail if nomail is set"""
not sending email to %s, as requested, here's the encrypted signed public key you can paste in your email client:
%s"""), (msg.mailto, msg.encrypted()))
%s"""), msg.mailto, msg.encrypted())
class EmailFactory:
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment