Merge "Remove references to 'sys.version_info'"

This commit is contained in:
Zuul 2021-05-03 14:21:56 +00:00 committed by Gerrit Code Review
commit 48b5bf94a3
4 changed files with 5 additions and 53 deletions

View File

@ -22,7 +22,6 @@ It is used via a single directive in the .rst file
import configparser
import re
import sys
from docutils import nodes
from docutils.parsers import rst
@ -158,16 +157,12 @@ class FeatureMatrixDirective(rst.Directive):
:returns: Matrix instance
"""
# SafeConfigParser was deprecated in Python 3.2
if sys.version_info >= (3, 2):
cfg = configparser.ConfigParser()
else:
cfg = configparser.SafeConfigParser()
cfg = configparser.ConfigParser()
env = self.state.document.settings.env
filename = self.arguments[0]
rel_fpath, fpath = env.relfn2path(filename)
with open(fpath) as fp:
cfg.readfp(fp)
cfg.read_file(fp)
# This ensures that the docs are rebuilt whenever the
# .ini file changes

View File

@ -21,7 +21,6 @@ Leverages websockify.py by Joel Martin
import copy
from http import cookies as Cookie
import socket
import sys
from urllib import parse as urlparse
from oslo_log import log as logging
@ -155,17 +154,9 @@ class NovaProxyRequestHandler(websockify.ProxyRequestHandler):
# The nova expected behavior is to have token
# passed to the method GET of the request
parse = urlparse.urlparse(self.path)
if parse.scheme not in ('http', 'https'):
# From a bug in urlparse in Python < 2.7.4 we cannot support
# special schemes (cf: http://bugs.python.org/issue9374)
if sys.version_info < (2, 7, 4):
raise exception.NovaException(
_("We do not support scheme '%s' under Python < 2.7.4, "
"please use http or https") % parse.scheme)
query = parse.query
token = urlparse.parse_qs(query).get("token", [""]).pop()
token = urlparse.parse_qs(
urlparse.urlparse(self.path).query
).get('token', ['']).pop()
if not token:
# NoVNC uses it's own convention that forward token
# from the request to a cookie header, we should check

View File

@ -356,34 +356,6 @@ class NovaProxyRequestHandlerTestCase(test.NoDBTestCase):
mock.call(len(HTTP_RESP))])
self.wh.do_proxy.assert_called_with(tsock)
@mock.patch.object(websocketproxy, 'sys')
@mock.patch('nova.console.websocketproxy.NovaProxyRequestHandler.'
'_check_console_port')
@mock.patch('nova.objects.ConsoleAuthToken.validate')
def test_new_websocket_client_py273_good_scheme(
self, validate, check_port, mock_sys):
mock_sys.version_info.return_value = (2, 7, 3)
params = {
'id': 1,
'token': '123-456-789',
'instance_uuid': uuids.instance,
'host': 'node1',
'port': '10000',
'console_type': 'novnc',
'access_url_base': 'https://example.net:6080'
}
validate.return_value = objects.ConsoleAuthToken(**params)
self.wh.socket.return_value = '<socket>'
self.wh.path = "http://127.0.0.1/?token=123-456-789"
self.wh.headers = self.fake_header
self.wh.new_websocket_client()
validate.assert_called_with(mock.ANY, "123-456-789")
self.wh.socket.assert_called_with('node1', 10000, connect=True)
self.wh.do_proxy.assert_called_with('<socket>')
@mock.patch('socket.getfqdn')
def test_address_string_doesnt_do_reverse_dns_lookup(self, getfqdn):
request_mock = mock.MagicMock()

View File

@ -14,8 +14,6 @@
# License for the specific language governing permissions and limitations
# under the License.
import sys
import mock
from oslo_service import fixture as service_fixture
from oslo_utils import encodeutils
@ -28,10 +26,6 @@ from nova.virt.libvirt import guest as libvirt_guest
from nova.virt.libvirt import host
if sys.version_info > (3,):
long = int
class GuestTestCase(test.NoDBTestCase):
def setUp(self):