Port to Python 3
This patch enables running all the unit tests (except the qpid ones that are skipped) under Python 3.3 and Python 3.4. Change-Id: I711663b4eedfb3cdeea7e6da7d28c6b92663e611
This commit is contained in:
parent
991cf14726
commit
4cb33ecc94
oslo/messaging
requirements-py3.txttest-requirements-py3.txttests
tox.ini@ -606,11 +606,11 @@ class Connection(object):
|
|||||||
try:
|
try:
|
||||||
self._connect(broker)
|
self._connect(broker)
|
||||||
return
|
return
|
||||||
except IOError as e:
|
except IOError as ex:
|
||||||
pass
|
e = ex
|
||||||
except self.connection_errors as e:
|
except self.connection_errors as ex:
|
||||||
pass
|
e = ex
|
||||||
except Exception as e:
|
except Exception as ex:
|
||||||
# NOTE(comstud): Unfortunately it's possible for amqplib
|
# NOTE(comstud): Unfortunately it's possible for amqplib
|
||||||
# to return an error not covered by its transport
|
# to return an error not covered by its transport
|
||||||
# connection_errors in the case of a timeout waiting for
|
# connection_errors in the case of a timeout waiting for
|
||||||
@ -619,6 +619,7 @@ class Connection(object):
|
|||||||
# and try to reconnect in this case.
|
# and try to reconnect in this case.
|
||||||
if 'timeout' not in six.text_type(e):
|
if 'timeout' not in six.text_type(e):
|
||||||
raise
|
raise
|
||||||
|
e = ex
|
||||||
|
|
||||||
log_info = {}
|
log_info = {}
|
||||||
log_info['err_str'] = e
|
log_info['err_str'] = e
|
||||||
|
@ -89,3 +89,6 @@ class Target(object):
|
|||||||
attrs.append((a, v))
|
attrs.append((a, v))
|
||||||
values = ', '.join(['%s=%s' % i for i in attrs])
|
values = ', '.join(['%s=%s' % i for i in attrs])
|
||||||
return '<Target ' + values + '>'
|
return '<Target ' + values + '>'
|
||||||
|
|
||||||
|
def __hash__(self):
|
||||||
|
return id(self)
|
||||||
|
20
requirements-py3.txt
Normal file
20
requirements-py3.txt
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
oslo.config>=1.2.1
|
||||||
|
stevedore>=0.14
|
||||||
|
|
||||||
|
# for timeutils
|
||||||
|
iso8601>=0.1.9
|
||||||
|
|
||||||
|
# for jsonutils
|
||||||
|
six>=1.7.0
|
||||||
|
|
||||||
|
# used by openstack/common/gettextutils.py
|
||||||
|
Babel>=1.3
|
||||||
|
|
||||||
|
# for the routing notifier
|
||||||
|
PyYAML>=3.1.0
|
||||||
|
|
||||||
|
# rabbit driver is the default
|
||||||
|
kombu>=2.4.8
|
||||||
|
|
||||||
|
# middleware
|
||||||
|
WebOb>=1.2.3
|
21
test-requirements-py3.txt
Normal file
21
test-requirements-py3.txt
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# Hacking already pins down pep8, pyflakes and flake8
|
||||||
|
hacking>=0.9.1,<0.10
|
||||||
|
|
||||||
|
discover
|
||||||
|
fixtures>=0.3.14
|
||||||
|
mock>=1.0
|
||||||
|
mox3>=0.7.0
|
||||||
|
python-subunit>=0.0.18
|
||||||
|
testrepository>=0.0.18
|
||||||
|
testscenarios>=0.4
|
||||||
|
testtools>=0.9.34
|
||||||
|
oslotest
|
||||||
|
|
||||||
|
# when we can require tox>= 1.4, this can go into tox.ini:
|
||||||
|
# [testenv:cover]
|
||||||
|
# deps = {[testenv]deps} coverage
|
||||||
|
coverage>=3.6
|
||||||
|
|
||||||
|
# this is required for the docs build jobs
|
||||||
|
sphinx>=1.1.2,!=1.2.0,<1.3
|
||||||
|
oslosphinx
|
@ -14,12 +14,16 @@
|
|||||||
|
|
||||||
import operator
|
import operator
|
||||||
import random
|
import random
|
||||||
import thread
|
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
|
import unittest
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
import qpid
|
try:
|
||||||
|
import qpid
|
||||||
|
except ImportError:
|
||||||
|
raise unittest.SkipTest("qpid not available")
|
||||||
|
from six.moves import _thread
|
||||||
import testscenarios
|
import testscenarios
|
||||||
|
|
||||||
from oslo import messaging
|
from oslo import messaging
|
||||||
@ -368,7 +372,7 @@ class TestQpidTopicAndFanout(_QpidBaseTestCase):
|
|||||||
msgcontent = msg
|
msgcontent = msg
|
||||||
|
|
||||||
splitmsg = msgcontent.split('-')
|
splitmsg = msgcontent.split('-')
|
||||||
key = thread.get_ident()
|
key = _thread.get_ident()
|
||||||
|
|
||||||
if key not in self._messages:
|
if key not in self._messages:
|
||||||
self._messages[key] = dict()
|
self._messages[key] = dict()
|
||||||
|
@ -16,8 +16,12 @@
|
|||||||
|
|
||||||
import contextlib
|
import contextlib
|
||||||
import threading
|
import threading
|
||||||
|
import unittest
|
||||||
|
|
||||||
import eventlet
|
try:
|
||||||
|
import eventlet
|
||||||
|
except ImportError:
|
||||||
|
raise unittest.SkipTest("Eventlet not available")
|
||||||
import mock
|
import mock
|
||||||
import testscenarios
|
import testscenarios
|
||||||
|
|
||||||
|
@ -382,7 +382,7 @@ group_2:
|
|||||||
return_value=self._fake_extension_manager(
|
return_value=self._fake_extension_manager(
|
||||||
mock.MagicMock())):
|
mock.MagicMock())):
|
||||||
self.router._load_notifiers()
|
self.router._load_notifiers()
|
||||||
groups = self.router.routing_groups.keys()
|
groups = list(self.router.routing_groups.keys())
|
||||||
groups.sort()
|
groups.sort()
|
||||||
self.assertEqual(['group_1', 'group_2'], groups)
|
self.assertEqual(['group_1', 'group_2'], groups)
|
||||||
|
|
||||||
|
@ -287,7 +287,7 @@ class TestRPCServer(test_utils.BaseTestCase, ServerSetupMixin):
|
|||||||
client.call({}, 'ping', arg='foo')
|
client.call({}, 'ping', arg='foo')
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
self.assertIsInstance(ex, ValueError)
|
self.assertIsInstance(ex, ValueError)
|
||||||
self.assertEqual('dsfoo', ex[0])
|
self.assertEqual('dsfoo', str(ex))
|
||||||
else:
|
else:
|
||||||
self.assertTrue(False)
|
self.assertTrue(False)
|
||||||
|
|
||||||
@ -308,7 +308,7 @@ class TestRPCServer(test_utils.BaseTestCase, ServerSetupMixin):
|
|||||||
client.call({}, 'ping', arg='foo')
|
client.call({}, 'ping', arg='foo')
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
self.assertIsInstance(ex, ValueError)
|
self.assertIsInstance(ex, ValueError)
|
||||||
self.assertEqual('dsfoo', ex[0])
|
self.assertEqual('dsfoo', str(ex))
|
||||||
else:
|
else:
|
||||||
self.assertTrue(False)
|
self.assertTrue(False)
|
||||||
|
|
||||||
|
@ -12,10 +12,16 @@
|
|||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# 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 unittest
|
||||||
|
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
|
|
||||||
from oslo.messaging import opts
|
try:
|
||||||
|
from oslo.messaging import opts
|
||||||
|
except ImportError:
|
||||||
|
import six
|
||||||
|
if six.PY3:
|
||||||
|
raise unittest.SkipTest
|
||||||
from tests import utils as test_utils
|
from tests import utils as test_utils
|
||||||
|
|
||||||
|
|
||||||
|
7
tox.ini
7
tox.ini
@ -1,5 +1,5 @@
|
|||||||
[tox]
|
[tox]
|
||||||
envlist = py26,py27,pep8
|
envlist = py33,py26,py27,pep8
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
setenv =
|
setenv =
|
||||||
@ -23,6 +23,10 @@ commands = {posargs}
|
|||||||
[testenv:docs]
|
[testenv:docs]
|
||||||
commands = python setup.py build_sphinx
|
commands = python setup.py build_sphinx
|
||||||
|
|
||||||
|
[testenv:py33]
|
||||||
|
deps = -r{toxinidir}/requirements-py3.txt
|
||||||
|
-r{toxinidir}/test-requirements-py3.txt
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
show-source = True
|
show-source = True
|
||||||
ignore = H237,H402,H405,H904
|
ignore = H237,H402,H405,H904
|
||||||
@ -32,3 +36,4 @@ builtins = _
|
|||||||
[hacking]
|
[hacking]
|
||||||
import_exceptions =
|
import_exceptions =
|
||||||
oslo.messaging.openstack.common.gettextutils
|
oslo.messaging.openstack.common.gettextutils
|
||||||
|
six.moves
|
||||||
|
Loading…
x
Reference in New Issue
Block a user