mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Patch PyTest's log handlers
This commit is contained in:
parent
2d2e1e1f96
commit
b3d82cb189
1 changed files with 28 additions and 2 deletions
|
@ -34,6 +34,7 @@ from tests.integration import TestDaemon
|
|||
|
||||
# Import pytest libs
|
||||
import pytest
|
||||
import _pytest.logging
|
||||
from _pytest.terminal import TerminalReporter
|
||||
|
||||
# Import 3rd-party libs
|
||||
|
@ -44,6 +45,7 @@ from salt.ext import six
|
|||
import salt.utils.files
|
||||
import salt.utils.path
|
||||
import salt.log.setup
|
||||
import salt.log.mixins
|
||||
from salt.utils.odict import OrderedDict
|
||||
|
||||
# Define the pytest plugins we rely on
|
||||
|
@ -52,13 +54,37 @@ pytest_plugins = ['tempdir', 'helpers_namespace', 'salt-runtests-bridge'] # pyl
|
|||
# Define where not to collect tests from
|
||||
collect_ignore = ['setup.py']
|
||||
|
||||
log = logging.getLogger('salt.testsuite')
|
||||
|
||||
# Patch PyTest logging handlers
|
||||
class LogCaptureHandler(salt.log.mixins.ExcInfoOnLogLevelFormatMixIn,
|
||||
_pytest.logging.LogCaptureHandler):
|
||||
'''
|
||||
Subclassing PyTest's LogCaptureHandler in order to add the
|
||||
exc_info_on_loglevel functionality.
|
||||
'''
|
||||
|
||||
|
||||
_pytest.logging.LogCaptureHandler = LogCaptureHandler
|
||||
|
||||
|
||||
class LiveLoggingStreamHandler(salt.log.mixins.ExcInfoOnLogLevelFormatMixIn,
|
||||
_pytest.logging._LiveLoggingStreamHandler):
|
||||
'''
|
||||
Subclassing PyTest's LiveLoggingStreamHandler in order to add the
|
||||
exc_info_on_loglevel functionality.
|
||||
'''
|
||||
|
||||
|
||||
_pytest.logging._LiveLoggingStreamHandler = LiveLoggingStreamHandler
|
||||
|
||||
# Reset logging root handlers
|
||||
for handler in logging.root.handlers:
|
||||
for handler in logging.root.handlers[:]:
|
||||
logging.root.removeHandler(handler)
|
||||
|
||||
|
||||
log = logging.getLogger('salt.testsuite')
|
||||
|
||||
|
||||
def pytest_tempdir_basename():
|
||||
'''
|
||||
Return the temporary directory basename for the salt test suite.
|
||||
|
|
Loading…
Add table
Reference in a new issue