summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Reyes <freyes@suse.com>2014-07-18 14:03:02 +0200
committerFelipe Reyes <freyes@suse.com>2014-07-18 14:03:02 +0200
commit69c2c3f78bb779408f62c453a6af9cb8e60eccf5 (patch)
tree207444a08ac7b98e336b5470577bd444d79b67e9
parent7d42c1075f5c566af371dbb74314b75496af6526 (diff)
downloadoslo-incubator-69c2c3f78bb779408f62c453a6af9cb8e60eccf5.tar.gz
Inherit MockWithCmp from Mock instead of MagicMock
This patch changes the base class for MockWithCmp and implements necessary methods to compare instances, because mock.MagicMock in python 3 raises NotImplemented exception on __lt__, __gt__, etc. Change-Id: I56f774a5bc27726dae66acb70bf12bc618cb96fb
-rw-r--r--tests/unit/db/sqlalchemy/test_migrate_cli.py20
-rw-r--r--tox.ini1
2 files changed, 20 insertions, 1 deletions
diff --git a/tests/unit/db/sqlalchemy/test_migrate_cli.py b/tests/unit/db/sqlalchemy/test_migrate_cli.py
index 9e33bf5a..be6bcdd1 100644
--- a/tests/unit/db/sqlalchemy/test_migrate_cli.py
+++ b/tests/unit/db/sqlalchemy/test_migrate_cli.py
@@ -18,13 +18,31 @@ from openstack.common.db.sqlalchemy.migration_cli import ext_migrate
from openstack.common.db.sqlalchemy.migration_cli import manager
-class MockWithCmp(mock.MagicMock):
+class MockWithCmp(mock.Mock):
order = 0
def __cmp__(self, other):
return self.order > other.order
+ def __lt__(self, other):
+ return self.order < other.order
+
+ def __le__(self, other):
+ return self.order <= other.order
+
+ def __eq__(self, other):
+ return self.order == other.order
+
+ def __ge__(self, other):
+ return self.order >= other.order
+
+ def __gt__(self, other):
+ return self.order > other.order
+
+ def __ne__(self, other):
+ return self.order != other.order
+
@mock.patch(('openstack.common.db.sqlalchemy.migration_cli.'
'ext_alembic.alembic.command'))
diff --git a/tox.ini b/tox.ini
index e85e7271..ae001611 100644
--- a/tox.ini
+++ b/tox.ini
@@ -72,6 +72,7 @@ commands =
tests.unit.cache.test_memory \
tests.unit.config.test_generator \
tests.unit.crypto.test_utils \
+ tests.unit.db.sqlalchemy.test_migrate_cli \
tests.unit.db.sqlalchemy.test_models \
tests.unit.db.sqlalchemy.test_options \
tests.unit.db.test_api \