test: add helpers methods muteLogging and unmuteLogging
This commit is contained in:
parent
cdff2852b4
commit
8bc634d4c2
1 changed files with 34 additions and 23 deletions
|
|
@ -22,7 +22,12 @@
|
|||
from sat.core import log_config
|
||||
log_config.satConfigure()
|
||||
|
||||
import logging
|
||||
from sat.core.log import getLogger
|
||||
getLogger().setLevel(logging.WARNING) # put this to DEBUG when needed
|
||||
|
||||
from sat.core import exceptions
|
||||
from sat.tools import config as tools_config
|
||||
from constants import Const as C
|
||||
from wokkel.xmppim import RosterItem
|
||||
from wokkel.generic import parseXml
|
||||
|
|
@ -47,6 +52,19 @@ def b2s(value):
|
|||
return u"True" if value else u"False"
|
||||
|
||||
|
||||
def muteLogging():
|
||||
"""Temporarily set the logging level to CRITICAL to not pollute the output with expected errors."""
|
||||
logger = getLogger()
|
||||
logger.original_level = logger.getEffectiveLevel()
|
||||
logger.setLevel(logging.CRITICAL)
|
||||
|
||||
|
||||
def unmuteLogging():
|
||||
"""Restore the logging level after it has been temporarily disabled."""
|
||||
logger = getLogger()
|
||||
logger.setLevel(logger.original_level)
|
||||
|
||||
|
||||
class DifferentArgsException(FailTest):
|
||||
pass
|
||||
|
||||
|
|
@ -340,7 +358,7 @@ class FakeRosterProtocol(SatRosterProtocol):
|
|||
SatRosterProtocol.__init__(self, host)
|
||||
self.parent = parent
|
||||
self._jids = {}
|
||||
self.addItem(parent.jid)
|
||||
self.addItem(parent.jid.userhostJID())
|
||||
|
||||
def addItem(self, jid, *args, **kwargs):
|
||||
if not args and not kwargs:
|
||||
|
|
|
|||
Loading…
Reference in a new issue