Fix tests to be Python 3 compatible

This commit includes small fixes in the test suite, such as proper
integer division, dealing with difference in iterators.

Partially-implements: blueprint py3k-support
Change-Id: I4140258f564a639697a130a213d8a7733bee7713
This commit is contained in:
Nataliia Uvarova
2014-06-13 20:15:58 +03:00
parent 83423b96eb
commit ce6859133e
6 changed files with 17 additions and 11 deletions

View File

@@ -21,6 +21,7 @@ import uuid
import mock
from pymongo import cursor
import pymongo.errors
import six
from testtools import matchers
from marconi.openstack.common.cache import cache as oslo_cache
@@ -179,7 +180,9 @@ class MongodbQueueTests(base.QueueControllerTest):
def test_raises_connection_error(self):
with mock.patch.object(cursor.Cursor, 'next', autospec=True) as method:
with mock.patch.object(cursor.Cursor,
'next' if six.PY2 else '__next__',
autospec=True) as method:
error = pymongo.errors.ConnectionFailure()
method.side_effect = error