diff options
author | Joshua Harlow <harlowja@yahoo-inc.com> | 2014-09-09 18:04:40 -0700 |
---|---|---|
committer | Joshua Harlow <harlowja@gmail.com> | 2014-09-27 14:53:12 -0700 |
commit | ce620c399a9e5cf2fd438d0193ba0d83da667a88 (patch) | |
tree | 7c939d1d9f6724109e5b2ec3360a837c405ff6c1 | |
parent | d43cc4f9c33a37d6a3a3f1a1eec7219a0804767b (diff) | |
download | taskflow-ce620c399a9e5cf2fd438d0193ba0d83da667a88.tar.gz |
Use oslotest to provide our base test case class
The oslotest library has a nice openstack testing integrated
base class that can ensure we setup our base test case using
the right logging fixtures, test timeouts, and output fixtures
that better operate in the openstack ecosystem.
This will also allow us to remove some of the functionality
that we currently have in our base test case and replace it with
the equivalent (or better) functionality that oslotest now
provides.
Part of blueprint use-oslo-test
Change-Id: I1602d5180ec8649a1899185972750ddddf65990f
-rw-r--r-- | taskflow/test.py | 13 | ||||
-rw-r--r-- | taskflow/tests/unit/jobs/base.py | 2 | ||||
-rw-r--r-- | taskflow/tests/unit/test_duration.py | 3 | ||||
-rw-r--r-- | taskflow/tests/unit/test_engine_helpers.py | 3 | ||||
-rw-r--r-- | taskflow/tests/unit/test_storage.py | 3 | ||||
-rw-r--r-- | taskflow/tests/unit/test_task.py | 3 | ||||
-rw-r--r-- | taskflow/tests/unit/worker_based/test_dispatcher.py | 2 | ||||
-rw-r--r-- | taskflow/tests/unit/worker_based/test_engine.py | 3 | ||||
-rw-r--r-- | taskflow/tests/unit/worker_based/test_executor.py | 2 | ||||
-rw-r--r-- | taskflow/tests/unit/worker_based/test_message_pump.py | 3 | ||||
-rw-r--r-- | taskflow/tests/unit/worker_based/test_protocol.py | 2 | ||||
-rw-r--r-- | taskflow/tests/unit/worker_based/test_proxy.py | 2 | ||||
-rw-r--r-- | taskflow/tests/unit/worker_based/test_server.py | 2 | ||||
-rw-r--r-- | taskflow/tests/unit/worker_based/test_worker.py | 3 | ||||
-rw-r--r-- | test-requirements.txt | 5 | ||||
-rw-r--r-- | tox.ini | 5 |
16 files changed, 29 insertions, 27 deletions
diff --git a/taskflow/test.py b/taskflow/test.py index 4de61d3..3d94df5 100644 --- a/taskflow/test.py +++ b/taskflow/test.py @@ -15,8 +15,15 @@ # under the License. import fixtures -import mock +from oslotest import base import six +try: + from six.moves import mock +except ImportError: + try: + from unittest import mock + except ImportError: + import mock from testtools import compat from testtools import matchers from testtools import testcase @@ -85,7 +92,7 @@ class ItemsEqual(object): return None -class TestCase(testcase.TestCase): +class TestCase(base.BaseTestCase): """Test case base class for all taskflow unit tests.""" def makeTmpDir(self): @@ -182,7 +189,7 @@ class TestCase(testcase.TestCase): self.assertThat(seq2, matcher) -class MockTestCase(TestCase): +class MockTestCase(base.BaseTestCase): def setUp(self): super(MockTestCase, self).setUp() diff --git a/taskflow/tests/unit/jobs/base.py b/taskflow/tests/unit/jobs/base.py index a178a8a..f8a2687 100644 --- a/taskflow/tests/unit/jobs/base.py +++ b/taskflow/tests/unit/jobs/base.py @@ -19,12 +19,12 @@ import threading import time from kazoo.recipe import watchers -import mock from taskflow import exceptions as excp from taskflow.openstack.common import uuidutils from taskflow.persistence.backends import impl_dir from taskflow import states +from taskflow.test import mock from taskflow.utils import misc from taskflow.utils import persistence_utils as p_utils diff --git a/taskflow/tests/unit/test_duration.py b/taskflow/tests/unit/test_duration.py index e1588eb..4738972 100644 --- a/taskflow/tests/unit/test_duration.py +++ b/taskflow/tests/unit/test_duration.py @@ -17,8 +17,6 @@ import contextlib import time -import mock - import taskflow.engines from taskflow import exceptions as exc from taskflow.listeners import timing @@ -26,6 +24,7 @@ from taskflow.patterns import linear_flow as lf from taskflow.persistence.backends import impl_memory from taskflow import task from taskflow import test +from taskflow.test import mock from taskflow.tests import utils as t_utils from taskflow.utils import persistence_utils as p_utils diff --git a/taskflow/tests/unit/test_engine_helpers.py b/taskflow/tests/unit/test_engine_helpers.py index fbf1756..2353d77 100644 --- a/taskflow/tests/unit/test_engine_helpers.py +++ b/taskflow/tests/unit/test_engine_helpers.py @@ -14,12 +14,11 @@ # License for the specific language governing permissions and limitations # under the License. -import mock - import taskflow.engines from taskflow import exceptions as exc from taskflow.patterns import linear_flow from taskflow import test +from taskflow.test import mock from taskflow.tests import utils as test_utils from taskflow.utils import persistence_utils as p_utils diff --git a/taskflow/tests/unit/test_storage.py b/taskflow/tests/unit/test_storage.py index 001cba9..94d7301 100644 --- a/taskflow/tests/unit/test_storage.py +++ b/taskflow/tests/unit/test_storage.py @@ -17,8 +17,6 @@ import contextlib import threading -import mock - from taskflow import exceptions from taskflow.openstack.common import uuidutils from taskflow.persistence import backends @@ -26,6 +24,7 @@ from taskflow.persistence import logbook from taskflow import states from taskflow import storage from taskflow import test +from taskflow.test import mock from taskflow.utils import misc from taskflow.utils import persistence_utils as p_utils diff --git a/taskflow/tests/unit/test_task.py b/taskflow/tests/unit/test_task.py index bcb7578..a3854d2 100644 --- a/taskflow/tests/unit/test_task.py +++ b/taskflow/tests/unit/test_task.py @@ -14,10 +14,9 @@ # License for the specific language governing permissions and limitations # under the License. -import mock - from taskflow import task from taskflow import test +from taskflow.test import mock from taskflow.utils import reflection diff --git a/taskflow/tests/unit/worker_based/test_dispatcher.py b/taskflow/tests/unit/worker_based/test_dispatcher.py index 4dae910..9b121d5 100644 --- a/taskflow/tests/unit/worker_based/test_dispatcher.py +++ b/taskflow/tests/unit/worker_based/test_dispatcher.py @@ -15,10 +15,10 @@ # under the License. from kombu import message -import mock from taskflow.engines.worker_based import dispatcher from taskflow import test +from taskflow.test import mock def mock_acked_message(ack_ok=True, **kwargs): diff --git a/taskflow/tests/unit/worker_based/test_engine.py b/taskflow/tests/unit/worker_based/test_engine.py index 531dfe5..ea322de 100644 --- a/taskflow/tests/unit/worker_based/test_engine.py +++ b/taskflow/tests/unit/worker_based/test_engine.py @@ -14,11 +14,10 @@ # License for the specific language governing permissions and limitations # under the License. -import mock - from taskflow.engines.worker_based import engine from taskflow.patterns import linear_flow as lf from taskflow import test +from taskflow.test import mock from taskflow.tests import utils from taskflow.utils import persistence_utils as pu diff --git a/taskflow/tests/unit/worker_based/test_executor.py b/taskflow/tests/unit/worker_based/test_executor.py index cc184df..c55c1c6 100644 --- a/taskflow/tests/unit/worker_based/test_executor.py +++ b/taskflow/tests/unit/worker_based/test_executor.py @@ -18,12 +18,12 @@ import threading import time from concurrent import futures -import mock from oslo.utils import timeutils from taskflow.engines.worker_based import executor from taskflow.engines.worker_based import protocol as pr from taskflow import test +from taskflow.test import mock from taskflow.tests import utils from taskflow.utils import misc diff --git a/taskflow/tests/unit/worker_based/test_message_pump.py b/taskflow/tests/unit/worker_based/test_message_pump.py index 10116c2..e2102b7 100644 --- a/taskflow/tests/unit/worker_based/test_message_pump.py +++ b/taskflow/tests/unit/worker_based/test_message_pump.py @@ -16,12 +16,11 @@ import threading -import mock - from taskflow.engines.worker_based import protocol as pr from taskflow.engines.worker_based import proxy from taskflow.openstack.common import uuidutils from taskflow import test +from taskflow.test import mock from taskflow.tests import utils as test_utils from taskflow.types import latch diff --git a/taskflow/tests/unit/worker_based/test_protocol.py b/taskflow/tests/unit/worker_based/test_protocol.py index 7d51da3..00a208e 100644 --- a/taskflow/tests/unit/worker_based/test_protocol.py +++ b/taskflow/tests/unit/worker_based/test_protocol.py @@ -15,12 +15,12 @@ # under the License. from concurrent import futures -import mock from taskflow.engines.worker_based import protocol as pr from taskflow import exceptions as excp from taskflow.openstack.common import uuidutils from taskflow import test +from taskflow.test import mock from taskflow.tests import utils from taskflow.utils import misc diff --git a/taskflow/tests/unit/worker_based/test_proxy.py b/taskflow/tests/unit/worker_based/test_proxy.py index e2dc02e..3c07596 100644 --- a/taskflow/tests/unit/worker_based/test_proxy.py +++ b/taskflow/tests/unit/worker_based/test_proxy.py @@ -17,7 +17,7 @@ import socket import threading -import mock +from six.moves import mock from taskflow.engines.worker_based import proxy from taskflow import test diff --git a/taskflow/tests/unit/worker_based/test_server.py b/taskflow/tests/unit/worker_based/test_server.py index 2a64c96..2759c49 100644 --- a/taskflow/tests/unit/worker_based/test_server.py +++ b/taskflow/tests/unit/worker_based/test_server.py @@ -14,13 +14,13 @@ # License for the specific language governing permissions and limitations # under the License. -import mock import six from taskflow.engines.worker_based import endpoint as ep from taskflow.engines.worker_based import protocol as pr from taskflow.engines.worker_based import server from taskflow import test +from taskflow.test import mock from taskflow.tests import utils from taskflow.utils import misc diff --git a/taskflow/tests/unit/worker_based/test_worker.py b/taskflow/tests/unit/worker_based/test_worker.py index c66255f..1777098 100644 --- a/taskflow/tests/unit/worker_based/test_worker.py +++ b/taskflow/tests/unit/worker_based/test_worker.py @@ -14,11 +14,10 @@ # License for the specific language governing permissions and limitations # under the License. -import mock - from taskflow.engines.worker_based import endpoint from taskflow.engines.worker_based import worker from taskflow import test +from taskflow.test import mock from taskflow.tests import utils from taskflow.utils import reflection diff --git a/test-requirements.txt b/test-requirements.txt index b72ca0b..d74dd5e 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -3,11 +3,8 @@ # process, which may cause wedges in the gate later. hacking>=0.9.2,<0.10 -discover -coverage>=3.6 +oslotest>=1.1.0 # Apache-2.0 mock>=1.0 -python-subunit>=0.0.18 -testrepository>=0.0.18 testtools>=0.9.34 # Used for testing the WBE engine. @@ -54,6 +54,11 @@ ignore = H904 builtins = _ exclude = .venv,.tox,dist,doc,./taskflow/openstack/common,*egg,.git,build,tools +[hacking] +import_exceptions = six.moves.mock + taskflow.test.mock + unittest.mock + # NOTE(imelnikov): pyXY envs are considered to be default, so they must have # richest set of test requirements [testenv:py26] |