Allow users to run 'tox -epy34'
With this commit, it is possible to successfully run 'tox -epy34', even though only a small amount of tests will actually be run. This is a required step in making Neutron compatible with Python 3, as described in the 'Porting to Python 3' specification. This commit: - fixes some broken imports, while making sure they still work with Python 3; - updates a call to gettext.install; - adds a py34 target in tox.ini. Change-Id: I91cc7a992d05ea85f7004d1c5a45a1c02cbf1c85 Blueprint: neutron-python3
This commit is contained in:
parent
62ccf394c2
commit
8db41f04d5
@ -23,7 +23,7 @@ responsible determining whether a command is safe to execute.
|
||||
"""
|
||||
from __future__ import print_function
|
||||
|
||||
import ConfigParser
|
||||
from six.moves import configparser as ConfigParser
|
||||
import json
|
||||
import os
|
||||
import select
|
||||
|
@ -14,6 +14,10 @@
|
||||
# under the License.
|
||||
|
||||
import gettext
|
||||
import six
|
||||
|
||||
|
||||
gettext.install('neutron', unicode=1)
|
||||
if six.PY2:
|
||||
gettext.install('neutron', unicode=1)
|
||||
else:
|
||||
gettext.install('neutron')
|
||||
|
@ -14,7 +14,7 @@
|
||||
#
|
||||
|
||||
import datetime
|
||||
import Queue
|
||||
from six.moves import queue as Queue
|
||||
|
||||
from oslo_utils import timeutils
|
||||
|
||||
|
@ -16,7 +16,6 @@
|
||||
import fcntl
|
||||
import glob
|
||||
import grp
|
||||
import httplib
|
||||
import os
|
||||
import pwd
|
||||
import shlex
|
||||
@ -33,6 +32,7 @@ from oslo_log import log as logging
|
||||
from oslo_log import loggers
|
||||
from oslo_rootwrap import client
|
||||
from oslo_utils import excutils
|
||||
from six.moves import http_client as httplib
|
||||
|
||||
from neutron.agent.common import config
|
||||
from neutron.common import constants
|
||||
|
@ -12,7 +12,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import Queue
|
||||
from six.moves import queue as Queue
|
||||
import time
|
||||
|
||||
from oslo_config import cfg
|
||||
|
@ -13,7 +13,7 @@
|
||||
# under the License.
|
||||
|
||||
import os
|
||||
import Queue
|
||||
from six.moves import queue as Queue
|
||||
import threading
|
||||
import traceback
|
||||
|
||||
|
@ -13,12 +13,12 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import ConfigParser
|
||||
import importlib
|
||||
import os
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from six.moves import configparser as ConfigParser
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
# under the License.
|
||||
|
||||
|
||||
import httplib
|
||||
from six.moves import http_client as httplib
|
||||
|
||||
# Topic for info notifications between the plugin and agent
|
||||
INFO = 'info'
|
||||
|
@ -15,7 +15,7 @@
|
||||
# under the License.
|
||||
|
||||
|
||||
import httplib
|
||||
from six.moves import http_client as httplib
|
||||
import urllib
|
||||
|
||||
import httplib2
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
"""Library to talk to NVSD controller."""
|
||||
|
||||
import httplib
|
||||
from six.moves import http_client as httplib
|
||||
import time
|
||||
|
||||
from oslo_config import cfg
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
import copy
|
||||
import hashlib
|
||||
import httplib
|
||||
from six.moves import http_client as httplib
|
||||
import json
|
||||
import posixpath
|
||||
import re
|
||||
|
@ -13,7 +13,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import ConfigParser
|
||||
from six.moves import configparser as ConfigParser
|
||||
import contextlib
|
||||
from tempest_lib import exceptions as lib_exc
|
||||
import types
|
||||
|
@ -13,7 +13,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import httplib
|
||||
from six.moves import http_client as httplib
|
||||
|
||||
from oslo_config import cfg
|
||||
from webob import exc
|
||||
|
@ -15,9 +15,6 @@
|
||||
|
||||
"""Test of Policy Engine For Neutron"""
|
||||
|
||||
import StringIO
|
||||
import urllib2
|
||||
|
||||
import mock
|
||||
from oslo_config import cfg
|
||||
from oslo_serialization import jsonutils
|
||||
@ -112,7 +109,7 @@ class PolicyTestCase(base.BaseTestCase):
|
||||
self.assertEqual(result, True)
|
||||
|
||||
@mock.patch.object(urlrequest, 'urlopen',
|
||||
return_value=StringIO.StringIO("True"))
|
||||
return_value=six.StringIO("True"))
|
||||
def test_enforce_http_true(self, mock_urlrequest):
|
||||
action = "example:get_http"
|
||||
target = {}
|
||||
@ -124,7 +121,7 @@ class PolicyTestCase(base.BaseTestCase):
|
||||
def fakeurlopen(url, post_data):
|
||||
return six.StringIO("False")
|
||||
|
||||
with mock.patch.object(urllib2, 'urlopen', new=fakeurlopen):
|
||||
with mock.patch.object(urlrequest, 'urlopen', new=fakeurlopen):
|
||||
action = "example:get_http"
|
||||
target = {}
|
||||
self.assertRaises(common_policy.PolicyNotAuthorized,
|
||||
|
@ -16,10 +16,10 @@
|
||||
import os
|
||||
import socket
|
||||
import ssl
|
||||
import urllib2
|
||||
|
||||
import mock
|
||||
from oslo_config import cfg
|
||||
import six.moves.urllib.request as urlrequest
|
||||
import testtools
|
||||
import webob
|
||||
import webob.exc
|
||||
@ -41,12 +41,12 @@ def open_no_proxy(*args, **kwargs):
|
||||
# introduced in python 2.7.9 under PEP-0476
|
||||
# https://github.com/python/peps/blob/master/pep-0476.txt
|
||||
if hasattr(ssl, "_create_unverified_context"):
|
||||
opener = urllib2.build_opener(
|
||||
urllib2.ProxyHandler({}),
|
||||
urllib2.HTTPSHandler(context=ssl._create_unverified_context())
|
||||
opener = urlrequest.build_opener(
|
||||
urlrequest.ProxyHandler({}),
|
||||
urlrequest.HTTPSHandler(context=ssl._create_unverified_context())
|
||||
)
|
||||
else:
|
||||
opener = urllib2.build_opener(urllib2.ProxyHandler({}))
|
||||
opener = urlrequest.build_opener(urlrequest.ProxyHandler({}))
|
||||
return opener.open(*args, **kwargs)
|
||||
|
||||
|
||||
|
7
tox.ini
7
tox.ini
@ -1,5 +1,5 @@
|
||||
[tox]
|
||||
envlist = py27,pep8
|
||||
envlist = py27,py34,pep8
|
||||
minversion = 1.8
|
||||
skipsdist = True
|
||||
|
||||
@ -96,6 +96,11 @@ commands = {posargs}
|
||||
[testenv:docs]
|
||||
commands = sphinx-build -W -b html doc/source doc/build
|
||||
|
||||
[testenv:py34]
|
||||
commands = python -m testtools.run \
|
||||
neutron.tests.fullstack.test_l3_agent \
|
||||
neutron.tests.unit.common.test_rpc
|
||||
|
||||
[flake8]
|
||||
# E125 continuation line does not distinguish itself from next logical line
|
||||
# E126 continuation line over-indented for hanging indent
|
||||
|
Loading…
Reference in New Issue
Block a user