From e882a4f16db0d4acc3a86b2285535ba17f71e9bb Mon Sep 17 00:00:00 2001 From: Anastasia Kuznetsova Date: Wed, 9 Sep 2015 12:23:43 +0300 Subject: [PATCH] Initial commit that fix py34 tests run Partial-Bug: #1378537 Change-Id: Ib32b66e8e9771bbc9957a4f2489d528aeb3d40d5 --- mistral/db/sqlalchemy/base.py | 4 +++- mistral/db/sqlalchemy/model_base.py | 2 ++ mistral/tests/__init__.py | 25 ------------------------- mistral/tests/base.py | 2 +- mistral/utils/__init__.py | 5 +++-- mistral/workbook/base.py | 6 +++--- tox.ini | 2 +- 7 files changed, 13 insertions(+), 33 deletions(-) diff --git a/mistral/db/sqlalchemy/base.py b/mistral/db/sqlalchemy/base.py index 37b1eb36..2385b6b3 100644 --- a/mistral/db/sqlalchemy/base.py +++ b/mistral/db/sqlalchemy/base.py @@ -14,6 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import six + from oslo_config import cfg from oslo_db import options from oslo_db.sqlalchemy import session as db_session @@ -42,7 +44,7 @@ def _get_facade(): cfg.CONF.database.connection, sqlite_fk=True, autocommit=False, - **dict(cfg.CONF.database.iteritems()) + **dict(six.iteritems(cfg.CONF.database)) ) return _facade diff --git a/mistral/db/sqlalchemy/model_base.py b/mistral/db/sqlalchemy/model_base.py index 7f72ace9..6c15489a 100644 --- a/mistral/db/sqlalchemy/model_base.py +++ b/mistral/db/sqlalchemy/model_base.py @@ -38,6 +38,8 @@ class _MistralModelBase(oslo_models.ModelBase, oslo_models.TimestampMixin): __table__ = None + __hash__ = object.__hash__ + def __init__(self, **kwargs): for key, value in kwargs.items(): setattr(self, key, value) diff --git a/mistral/tests/__init__.py b/mistral/tests/__init__.py index 4c7803c6..e69de29b 100644 --- a/mistral/tests/__init__.py +++ b/mistral/tests/__init__.py @@ -1,25 +0,0 @@ -# Copyright 2015 - Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import eventlet -import sys - - -eventlet.monkey_patch( - os=True, - select=True, - socket=True, - thread=False if '--use-debugger' in sys.argv else True, - time=True -) diff --git a/mistral/tests/base.py b/mistral/tests/base.py index 2c08c041..cabecaaf 100644 --- a/mistral/tests/base.py +++ b/mistral/tests/base.py @@ -127,7 +127,7 @@ class BaseTest(base.BaseTestCase): filtered_items = filter(lambda item: _matches(item, **props), items) - found = len(filtered_items) + found = len(list(filtered_items)) if found != count: LOG.info("[failed test ctx] items=%s, expected_props=%s" % (str( diff --git a/mistral/utils/__init__.py b/mistral/utils/__init__.py index e0719c08..fde28047 100644 --- a/mistral/utils/__init__.py +++ b/mistral/utils/__init__.py @@ -19,6 +19,7 @@ import json import logging import os from os import path +import six import socket import threading import uuid @@ -37,7 +38,7 @@ _th_loc_storage = threading.local() def generate_unicode_uuid(): - return unicode(str(uuid.uuid4())) + return six.text_type(str(uuid.uuid4())) def _get_greenlet_local_storage(): @@ -127,7 +128,7 @@ def merge_dicts(left, right, overwrite=True): if right is None: return left - for k, v in right.iteritems(): + for k, v in six.iteritems(right): if k not in left: left[k] = v else: diff --git a/mistral/workbook/base.py b/mistral/workbook/base.py index 9a0fe6ab..b90f8be8 100644 --- a/mistral/workbook/base.py +++ b/mistral/workbook/base.py @@ -320,7 +320,7 @@ class BaseListSpec(BaseSpec): self.items = [] - for k, v in data.iteritems(): + for k, v in six.iteritems(data): if k != 'version': v['name'] = k self._inject_version([k]) @@ -353,7 +353,7 @@ class BaseSpecList(object): def __init__(self, data): self.items = {} - for k, v in data.iteritems(): + for k, v in six.iteritems(data): if k != 'version': v['name'] = k v['version'] = self._version @@ -363,7 +363,7 @@ class BaseSpecList(object): return self.items.keys() def __iter__(self): - return self.items.itervalues() + return six.itervalues(self.items) def __getitem__(self, name): return self.items.get(name) diff --git a/tox.ini b/tox.ini index bc258713..494292df 100644 --- a/tox.ini +++ b/tox.ini @@ -11,7 +11,7 @@ setenv = VIRTUAL_ENV={envdir} PYTHONDONTWRITEBYTECODE = 1 deps = -r{toxinidir}/test-requirements.txt commands = - python setup.py test --slowest --testr-args='{posargs}' + python setup.py testr --slowest --testr-args='{posargs}' whitelist_externals = rm [testenv:unit-postgresql]