From: Kefu Chai Date: Wed, 17 Jun 2020 09:57:26 +0000 (+0800) Subject: teuthology/orchestra: drop six X-Git-Tag: 1.1.0~86^2~12 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=f05deb85e194cefa6bc8f5062c10866e08d812ec;p=teuthology.git teuthology/orchestra: drop six Signed-off-by: Kefu Chai --- diff --git a/teuthology/orchestra/remote.py b/teuthology/orchestra/remote.py index 8bb02f22dc..4ecff4c249 100644 --- a/teuthology/orchestra/remote.py +++ b/teuthology/orchestra/remote.py @@ -2,8 +2,6 @@ Support for paramiko remote objects. """ -from six import ensure_str - import teuthology.lock.query import teuthology.lock.util from teuthology.orchestra import run @@ -247,9 +245,12 @@ class Remote(object): kwargs['stdout'] = BytesIO() if 'args' not in kwargs: kwargs['args'] = script - proc=self.run(**kwargs) - out=proc.stdout.getvalue() - return ensure_str(out) + proc = self.run(**kwargs) + out = proc.stdout.getvalue() + if isinstance(out, bytes): + return out.decode() + else: + return out def sh_file(self, script, label="script", sudo=False, **kwargs): """ diff --git a/teuthology/orchestra/test/test_run.py b/teuthology/orchestra/test/test_run.py index e7a5462340..074d90b05d 100644 --- a/teuthology/orchestra/test/test_run.py +++ b/teuthology/orchestra/test/test_run.py @@ -6,8 +6,6 @@ import socket from mock import MagicMock, patch from pytest import raises -from six import ensure_str, ensure_binary, PY2 - from teuthology.orchestra import run from teuthology.exceptions import (CommandCrashedError, CommandFailedError, ConnectionLostError) @@ -19,7 +17,7 @@ def set_buffer_contents(buf, contents): elif isinstance(contents, (list, tuple)): buf.writelines(contents) elif isinstance(contents, str): - buf.write(ensure_binary(contents)) + buf.write(contents.encode()) else: raise TypeError( "%s is a %s; should be a byte string, list or tuple" % ( @@ -109,8 +107,8 @@ class TestRun(object): stdout=stdout, ) assert proc.stdout is stdout - assert ensure_str(proc.stdout.read()) == output - assert ensure_str(proc.stdout.getvalue()) == output + assert proc.stdout.read().decode() == output + assert proc.stdout.getvalue().decode() == output def test_capture_stderr_newline(self): output = 'foo\nbar\n' @@ -123,8 +121,8 @@ class TestRun(object): stderr=stderr, ) assert proc.stderr is stderr - assert ensure_str(proc.stderr.read()) == output - assert ensure_str(proc.stderr.getvalue()) == output + assert proc.stderr.read().decode() == output + assert proc.stderr.getvalue().decode() == output def test_status_bad(self): self.m_stdout_buf.channel.recv_exit_status.return_value = 42 @@ -264,9 +262,6 @@ class TestRun(object): run.copy_and_close(None, MagicMock()) run.copy_and_close('', MagicMock()) run.copy_and_close(b'', MagicMock()) - if PY2: - run.copy_and_close(u'', MagicMock()) - class TestQuote(object):