Make test logging setup fixture disable future setup

Our logging fixture sets up logging in a way that we need to capture
things during tests. However, some of our tests do things like call
back into main functions, which then call logging setup again, and
unwind everything we're doing (including debug message testing).

This patches out oslo_log setup after the fixture runs, thus ignoring
calls to it in the future. It removes a couple of scary looking stack
traces from the test stream that shouldn't be there.

Change-Id: Ie1b7d4370f20597961a841c5bc0a1ad7cc42b2ef
This commit is contained in:
Sean Dague 2016-09-22 07:44:24 -04:00
parent d18eff38eb
commit dc2f4f88ac

View File

@ -143,6 +143,17 @@ class StandardLogging(fixtures.Fixture):
std_logging.getLogger(
'migrate.versioning.api').setLevel(std_logging.WARNING)
# At times we end up calling back into main() functions in
# testing. This has the possibility of calling logging.setup
# again, which completely unwinds the logging capture we've
# created here. Once we've setup the logging the way we want,
# disable the ability for the test to change this.
def fake_logging_setup(*args):
pass
self.useFixture(
fixtures.MonkeyPatch('oslo_log.log.setup', fake_logging_setup))
class OutputStreamCapture(fixtures.Fixture):
"""Capture output streams during tests.