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
This commit is contained in:
committed by
Joshua Harlow
parent
d43cc4f9c3
commit
ce620c399a
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
5
tox.ini
5
tox.ini
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user