issue #436: decode debug log lines on Python 3.

issue510
David Wilson 6 years ago
parent 8380baf41b
commit a8c056c27b

@ -100,7 +100,8 @@ def filter_debug(stream, it):
if b('\n') not in buf:
break
line, _, buf = buf.partition(b('\n'))
LOG.debug('%r: %s', stream, line.rstrip())
LOG.debug('%r: %s', stream,
mitogen.core.to_text(line.rstrip()))
state = 'start_of_line'
elif state == 'in_plain':
line, nl, buf = buf.partition(b('\n'))

@ -44,6 +44,21 @@ class ConstructorTest(testlib.RouterMixin, testlib.TestCase):
class SshTest(testlib.DockerMixin, testlib.TestCase):
stream_class = mitogen.ssh.Stream
def test_debug_decoding(self):
# ensure filter_debug_logs() decodes the logged string.
capture = testlib.LogCapturer()
capture.start()
try:
context = self.docker_ssh(
username='mitogen__has_sudo',
password='has_sudo_password',
ssh_debug_level=3,
)
finally:
s = capture.stop()
self.assertTrue("'): debug1: Reading configuration data" in s)
def test_stream_name(self):
context = self.docker_ssh(
username='mitogen__has_sudo',

Loading…
Cancel
Save