diff options
author | Lucas Hoffmann <lucc@posteo.de> | 2018-10-11 12:47:18 +0200 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2018-11-11 13:50:11 +0000 |
commit | 5d01c19644913088d11a6f350e0935de1c7fa84d (patch) | |
tree | 15530443aaeb8a2940a696a56bc71da2f949f192 | |
parent | 7fd1bfc05748057081fcc63f3ae4bb2746b1e8ed (diff) |
Assert some logging messages to silence them
The logging messages appear in between the test output. By asserting
them they are hidden from the output.
-rw-r--r-- | tests/account_test.py | 4 | ||||
-rw-r--r-- | tests/commands/global_test.py | 10 |
2 files changed, 9 insertions, 5 deletions
diff --git a/tests/account_test.py b/tests/account_test.py index c1fca557..9f6287be 100644 --- a/tests/account_test.py +++ b/tests/account_test.py @@ -15,6 +15,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. +import logging import unittest from alot import account @@ -172,4 +173,5 @@ class TestSend(unittest.TestCase): async def test_failing_sendmail_command_is_noticed(self): a = account.SendmailAccount(address="test@alot.dev", cmd="false") with self.assertRaises(account.SendingMailFailed): - await a.send_mail("some text") + with self.assertLogs(level=logging.ERROR): + await a.send_mail("some text") diff --git a/tests/commands/global_test.py b/tests/commands/global_test.py index 48ddd34d..e5503305 100644 --- a/tests/commands/global_test.py +++ b/tests/commands/global_test.py @@ -16,6 +16,7 @@ """Tests for global commands.""" +import logging import os import tempfile import unittest @@ -112,10 +113,11 @@ class TestComposeCommand(unittest.TestCase): mock.Mock(return_value=[account])): with mock.patch('alot.commands.globals.settings.get_addressbooks', mock.Mock(side_effect=Stop)): - try: - await cmd.apply(mock.Mock()) - except Stop: - pass + with self.assertLogs(level=logging.WARNING): + try: + await cmd.apply(mock.Mock()) + except Stop: + pass self.assertFalse(envelope.sign) self.assertIs(envelope.sign_key, None) |