Fix inheritance for BaseTestCase
This commit fixes the inheritance around the BaseTestCase definition.
Previously there were a couple of things wrong with it, first the
mixin order was incorrect, secondly the use of ResourcedTestCase
wasn't actually needed since testresources isn't actually used
anywhere. The other part of the fix was the hack for python2.6 to
also add unittest2 to BaseTestCase is not needed now, because
testtools now uses unittest2.
As a part of this fix the base CLI test class has to be reworked to
change how tempest-lib is used. By fixing the inheritance on
BaseTestCase a conflict occurs with the class test used from
tempest-lib. The recommended usage pattern for tempest-lib will have
to be rethought. But, in the mean time this commit just adds the code
which would be inherited from the mixin in tempest-lib directly. It
should be removed when tempest-lib is updated to accommodate this use
case.
Change-Id: Ia5dda59f7989f37997276cbd19bb9fdc7b7d2624
diff --git a/requirements.txt b/requirements.txt
index ac72017..4a889a8 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -20,7 +20,6 @@
python-ironicclient>=0.2.1
python-saharaclient>=0.7.3
python-swiftclient>=2.2.0
-testresources>=0.2.4
testrepository>=0.0.18
oslo.config>=1.4.0 # Apache-2.0
six>=1.7.0
diff --git a/tempest/cli/__init__.py b/tempest/cli/__init__.py
index 8dd2df2..4782129 100644
--- a/tempest/cli/__init__.py
+++ b/tempest/cli/__init__.py
@@ -16,6 +16,7 @@
import functools
from tempest_lib.cli import base
+from tempest_lib.cli import output_parser
import testtools
from tempest.common import credentials
@@ -66,7 +67,7 @@
return decorator
-class ClientTestBase(base.ClientTestBase, test.BaseTestCase):
+class ClientTestBase(test.BaseTestCase):
@classmethod
def resource_setup(cls):
if not CONF.cli.enabled:
@@ -82,3 +83,36 @@
self.creds.tenant_name,
CONF.identity.uri, CONF.cli.cli_dir)
return clients
+
+ # TODO(mtreinish): The following code is basically copied from tempest-lib.
+ # The base cli test class in tempest-lib 0.0.1 doesn't work as a mixin like
+ # is needed here. The code below should be removed when tempest-lib
+ # provides a way to provide this functionality
+ def setUp(self):
+ super(ClientTestBase, self).setUp()
+ self.clients = self._get_clients()
+ self.parser = output_parser
+
+ def assertTableStruct(self, items, field_names):
+ """Verify that all items has keys listed in field_names.
+
+ :param items: items to assert are field names in the output table
+ :type items: list
+ :param field_names: field names from the output table of the cmd
+ :type field_names: list
+ """
+ for item in items:
+ for field in field_names:
+ self.assertIn(field, item)
+
+ def assertFirstLineStartsWith(self, lines, beginning):
+ """Verify that the first line starts with a string
+
+ :param lines: strings for each line of output
+ :type lines: list
+ :param beginning: verify this is at the beginning of the first line
+ :type beginning: string
+ """
+ self.assertTrue(lines[0].startswith(beginning),
+ msg=('Beginning of first line has invalid content: %s'
+ % lines[:3]))
diff --git a/tempest/test.py b/tempest/test.py
index db8736e..14cf3bb 100644
--- a/tempest/test.py
+++ b/tempest/test.py
@@ -24,7 +24,6 @@
import uuid
import fixtures
-import testresources
import testscenarios
import testtools
@@ -222,23 +221,9 @@
atexit.register(validate_tearDownClass)
-if sys.version_info >= (2, 7):
- class BaseDeps(testtools.TestCase,
- testtools.testcase.WithAttributes,
- testresources.ResourcedTestCase):
- pass
-else:
- # Define asserts for py26
- import unittest2
- class BaseDeps(testtools.TestCase,
- testtools.testcase.WithAttributes,
- testresources.ResourcedTestCase,
- unittest2.TestCase):
- pass
-
-
-class BaseTestCase(BaseDeps):
+class BaseTestCase(testtools.testcase.WithAttributes,
+ testtools.TestCase):
setUpClassCalled = False
_service = None