Merge "Remove six.PY3/six.PY2"
This commit is contained in:
commit
05628f2e91
|
@ -26,11 +26,6 @@ from tempest.lib import decorators
|
||||||
|
|
||||||
CONF = config.CONF
|
CONF = config.CONF
|
||||||
|
|
||||||
if six.PY2:
|
|
||||||
ord_func = ord
|
|
||||||
else:
|
|
||||||
ord_func = int
|
|
||||||
|
|
||||||
|
|
||||||
class NoVNCConsoleTestJSON(base.BaseV2ComputeTest):
|
class NoVNCConsoleTestJSON(base.BaseV2ComputeTest):
|
||||||
"""Test novnc console"""
|
"""Test novnc console"""
|
||||||
|
@ -116,14 +111,14 @@ class NoVNCConsoleTestJSON(base.BaseV2ComputeTest):
|
||||||
# single word(4 bytes).
|
# single word(4 bytes).
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
data_length, 4, 'Expected authentication type None.')
|
data_length, 4, 'Expected authentication type None.')
|
||||||
self.assertIn(1, [ord_func(data[i]) for i in (0, 3)],
|
self.assertIn(1, [int(data[i]) for i in (0, 3)],
|
||||||
'Expected authentication type None.')
|
'Expected authentication type None.')
|
||||||
else:
|
else:
|
||||||
self.assertGreaterEqual(
|
self.assertGreaterEqual(
|
||||||
len(data), 2, 'Expected authentication type None.')
|
len(data), 2, 'Expected authentication type None.')
|
||||||
self.assertIn(
|
self.assertIn(
|
||||||
1,
|
1,
|
||||||
[ord_func(data[i + 1]) for i in range(ord_func(data[0]))],
|
[int(data[i + 1]) for i in range(int(data[0]))],
|
||||||
'Expected authentication type None.')
|
'Expected authentication type None.')
|
||||||
# Send to the server that we only support authentication
|
# Send to the server that we only support authentication
|
||||||
# type None
|
# type None
|
||||||
|
@ -136,7 +131,7 @@ class NoVNCConsoleTestJSON(base.BaseV2ComputeTest):
|
||||||
len(data), 4,
|
len(data), 4,
|
||||||
'Server did not think security was successful.')
|
'Server did not think security was successful.')
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
[ord_func(i) for i in data], [0, 0, 0, 0],
|
[int(i) for i in data], [0, 0, 0, 0],
|
||||||
'Server did not think security was successful.')
|
'Server did not think security was successful.')
|
||||||
|
|
||||||
# Say to leave the desktop as shared as part of client initialization
|
# Say to leave the desktop as shared as part of client initialization
|
||||||
|
|
|
@ -129,7 +129,6 @@ import sys
|
||||||
|
|
||||||
from cliff import command
|
from cliff import command
|
||||||
from oslo_serialization import jsonutils as json
|
from oslo_serialization import jsonutils as json
|
||||||
import six
|
|
||||||
from stestr import commands
|
from stestr import commands
|
||||||
|
|
||||||
from tempest import clients
|
from tempest import clients
|
||||||
|
@ -139,10 +138,6 @@ from tempest.cmd import workspace
|
||||||
from tempest.common import credentials_factory as credentials
|
from tempest.common import credentials_factory as credentials
|
||||||
from tempest import config
|
from tempest import config
|
||||||
|
|
||||||
if six.PY2:
|
|
||||||
# Python 2 has not FileNotFoundError exception
|
|
||||||
FileNotFoundError = IOError
|
|
||||||
|
|
||||||
CONF = config.CONF
|
CONF = config.CONF
|
||||||
SAVED_STATE_JSON = "saved_state.json"
|
SAVED_STATE_JSON = "saved_state.json"
|
||||||
|
|
||||||
|
@ -167,7 +162,7 @@ class TempestRun(command.Command):
|
||||||
# environment variable and fall back to "python", under python3
|
# environment variable and fall back to "python", under python3
|
||||||
# if it does not exist. we should set it to the python3 executable
|
# if it does not exist. we should set it to the python3 executable
|
||||||
# to deal with this situation better for now.
|
# to deal with this situation better for now.
|
||||||
if six.PY3 and 'PYTHON' not in os.environ:
|
if 'PYTHON' not in os.environ:
|
||||||
os.environ['PYTHON'] = sys.executable
|
os.environ['PYTHON'] = sys.executable
|
||||||
|
|
||||||
def _create_stestr_conf(self):
|
def _create_stestr_conf(self):
|
||||||
|
|
|
@ -19,7 +19,6 @@ import ssl
|
||||||
import struct
|
import struct
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
import six
|
|
||||||
from six.moves.urllib import parse as urlparse
|
from six.moves.urllib import parse as urlparse
|
||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
@ -31,11 +30,6 @@ from tempest.lib.common import fixed_network
|
||||||
from tempest.lib.common import rest_client
|
from tempest.lib.common import rest_client
|
||||||
from tempest.lib.common.utils import data_utils
|
from tempest.lib.common.utils import data_utils
|
||||||
|
|
||||||
if six.PY2:
|
|
||||||
ord_func = ord
|
|
||||||
else:
|
|
||||||
ord_func = int
|
|
||||||
|
|
||||||
CONF = config.CONF
|
CONF = config.CONF
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
@ -371,8 +365,8 @@ class _WebSocket(object):
|
||||||
# frames less than 125 bytes here (for the negotiation) and
|
# frames less than 125 bytes here (for the negotiation) and
|
||||||
# that only the 2nd byte contains the length, and since the
|
# that only the 2nd byte contains the length, and since the
|
||||||
# server doesn't do masking, we can just read the data length
|
# server doesn't do masking, we can just read the data length
|
||||||
if ord_func(header[1]) & 127 > 0:
|
if int(header[1]) & 127 > 0:
|
||||||
return self._recv(ord_func(header[1]) & 127)
|
return self._recv(int(header[1]) & 127)
|
||||||
|
|
||||||
def send_frame(self, data):
|
def send_frame(self, data):
|
||||||
"""Wrapper for sending data to add in the WebSocket frame format."""
|
"""Wrapper for sending data to add in the WebSocket frame format."""
|
||||||
|
@ -389,7 +383,7 @@ class _WebSocket(object):
|
||||||
frame_bytes.append(mask[i])
|
frame_bytes.append(mask[i])
|
||||||
# Mask each of the actual data bytes that we are going to send
|
# Mask each of the actual data bytes that we are going to send
|
||||||
for i in range(len(data)):
|
for i in range(len(data)):
|
||||||
frame_bytes.append(ord_func(data[i]) ^ mask[i % 4])
|
frame_bytes.append(int(data[i]) ^ mask[i % 4])
|
||||||
# Convert our integer list to a binary array of bytes
|
# Convert our integer list to a binary array of bytes
|
||||||
frame_bytes = struct.pack('!%iB' % len(frame_bytes), * frame_bytes)
|
frame_bytes = struct.pack('!%iB' % len(frame_bytes), * frame_bytes)
|
||||||
self._socket.sendall(frame_bytes)
|
self._socket.sendall(frame_bytes)
|
||||||
|
|
|
@ -18,7 +18,6 @@ import shlex
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
import six
|
|
||||||
|
|
||||||
from tempest.lib import base
|
from tempest.lib import base
|
||||||
import tempest.lib.cli.output_parser
|
import tempest.lib.cli.output_parser
|
||||||
|
@ -55,8 +54,6 @@ def execute(cmd, action, flags='', params='', fail_ok=False,
|
||||||
flags, action, params])
|
flags, action, params])
|
||||||
cmd = cmd.strip()
|
cmd = cmd.strip()
|
||||||
LOG.info("running: '%s'", cmd)
|
LOG.info("running: '%s'", cmd)
|
||||||
if six.PY2:
|
|
||||||
cmd = cmd.encode('utf-8')
|
|
||||||
cmd = shlex.split(cmd)
|
cmd = shlex.split(cmd)
|
||||||
stdout = subprocess.PIPE
|
stdout = subprocess.PIPE
|
||||||
stderr = subprocess.STDOUT if merge_stderr else subprocess.PIPE
|
stderr = subprocess.STDOUT if merge_stderr else subprocess.PIPE
|
||||||
|
@ -67,10 +64,7 @@ def execute(cmd, action, flags='', params='', fail_ok=False,
|
||||||
cmd,
|
cmd,
|
||||||
result,
|
result,
|
||||||
result_err)
|
result_err)
|
||||||
if six.PY2:
|
return os.fsdecode(result)
|
||||||
return result
|
|
||||||
else:
|
|
||||||
return os.fsdecode(result)
|
|
||||||
|
|
||||||
|
|
||||||
class CLIClient(object):
|
class CLIClient(object):
|
||||||
|
|
|
@ -13,13 +13,6 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import six
|
# On Python3 thread module has been deprecated and get_ident has been moved
|
||||||
|
# to threading module
|
||||||
if six.PY2:
|
from threading import get_ident # noqa: F401
|
||||||
# module thread is removed in Python 3
|
|
||||||
from thread import get_ident # noqa: H237,F401
|
|
||||||
|
|
||||||
else:
|
|
||||||
# On Python3 thread module has been deprecated and get_ident has been moved
|
|
||||||
# to threading module
|
|
||||||
from threading import get_ident # noqa: F401
|
|
||||||
|
|
|
@ -29,10 +29,6 @@ from tempest import config
|
||||||
from tempest.lib.common.utils import data_utils
|
from tempest.lib.common.utils import data_utils
|
||||||
from tempest.tests import base
|
from tempest.tests import base
|
||||||
|
|
||||||
if six.PY2:
|
|
||||||
# Python 2 has not FileNotFoundError exception
|
|
||||||
FileNotFoundError = IOError
|
|
||||||
|
|
||||||
DEVNULL = open(os.devnull, 'wb')
|
DEVNULL = open(os.devnull, 'wb')
|
||||||
atexit.register(DEVNULL.close)
|
atexit.register(DEVNULL.close)
|
||||||
|
|
||||||
|
@ -149,8 +145,7 @@ class TestRunReturnCode(base.TestCase):
|
||||||
]
|
]
|
||||||
# NOTE(mtreinish): on python 3 the subprocess prints b'' around
|
# NOTE(mtreinish): on python 3 the subprocess prints b'' around
|
||||||
# stdout.
|
# stdout.
|
||||||
if six.PY3:
|
result = ["b\'" + x + "\'" for x in result]
|
||||||
result = ["b\'" + x + "\'" for x in result]
|
|
||||||
self.assertEqual(result, tests)
|
self.assertEqual(result, tests)
|
||||||
|
|
||||||
def test_tempest_run_with_worker_file(self):
|
def test_tempest_run_with_worker_file(self):
|
||||||
|
|
Loading…
Reference in New Issue