py36: Fix test_get_logger_sysloghandler_plumbing

Change-Id: Ibdb9e2bbec1c962d930a3f69fc95a8c562ac13b7
This commit is contained in:
Tim Burke 2018-06-21 15:43:26 -07:00
parent 2637fec004
commit 1318bacc17

View File

@ -1605,8 +1605,16 @@ class TestUtils(unittest.TestCase):
syslog_handler_catcher.LOG_LOCAL0 = orig_sysloghandler.LOG_LOCAL0
syslog_handler_catcher.LOG_LOCAL3 = orig_sysloghandler.LOG_LOCAL3
# Some versions of python perform host resolution while initializing
# the handler. See https://bugs.python.org/issue30378
orig_getaddrinfo = socket.getaddrinfo
def fake_getaddrinfo(host, *args):
return orig_getaddrinfo('localhost', *args)
with mock.patch.object(utils, 'ThreadSafeSysLogHandler',
syslog_handler_catcher):
syslog_handler_catcher), \
mock.patch.object(socket, 'getaddrinfo', fake_getaddrinfo):
utils.get_logger({
'log_facility': 'LOG_LOCAL3',
}, 'server', log_route='server')