Merge "Have all test case to use a single base class"
diff --git a/tempest/smoke.py b/tempest/smoke.py
index 1e7da8e..0d4043f 100644
--- a/tempest/smoke.py
+++ b/tempest/smoke.py
@@ -51,8 +51,8 @@
         # order, and because test methods in smoke tests generally create
         # resources in a particular order, we destroy resources in the reverse
         # order in which resources are added to the smoke test class object
-        while cls.resources:
-            thing = cls.resources.pop()
+        while cls.os_resources:
+            thing = cls.os_resources.pop()
             LOG.debug("Deleting %r from shared resources of %s" %
                       (thing, cls.__name__))
 
diff --git a/tempest/test.py b/tempest/test.py
index 616a866..90793ac 100644
--- a/tempest/test.py
+++ b/tempest/test.py
@@ -19,8 +19,10 @@
 import time
 
 import nose.plugins.attrib
+import testresources
 import testtools
 
+from tempest import config
 from tempest import manager
 
 LOG = logging.getLogger(__name__)
@@ -46,7 +48,16 @@
     return decorator
 
 
-class TestCase(testtools.TestCase):
+class BaseTestCase(testtools.TestCase,
+                   testtools.testcase.WithAttributes,
+                   testresources.ResourcedTestCase):
+    def __init__(self, *args, **kwargs):
+        super(BaseTestCase, self).__init__(*args, **kwargs)
+        #NOTE(afazekas): inspection workaround
+        BaseTestCase.config = config.TempestConfig()
+
+
+class TestCase(BaseTestCase):
 
     """
     Base test case class for all Tempest tests
@@ -58,7 +69,6 @@
     @classmethod
     def setUpClass(cls):
         cls.manager = cls.manager_class()
-        cls.config = cls.manager.config
         for attr_name in cls.manager.client_attr_names:
             # Ensure that pre-existing class attributes won't be
             # accidentally overriden.
@@ -66,20 +76,20 @@
             client = getattr(cls.manager, attr_name)
             setattr(cls, attr_name, client)
         cls.resource_keys = {}
-        cls.resources = []
+        cls.os_resources = []
 
     def set_resource(self, key, thing):
         LOG.debug("Adding %r to shared resources of %s" %
                   (thing, self.__class__.__name__))
         self.resource_keys[key] = thing
-        self.resources.append(thing)
+        self.os_resources.append(thing)
 
     def get_resource(self, key):
         return self.resource_keys[key]
 
     def remove_resource(self, key):
         thing = self.resource_keys[key]
-        self.resources.remove(thing)
+        self.os_resources.remove(thing)
         del self.resource_keys[key]
 
 
diff --git a/tempest/testboto.py b/tempest/testboto.py
index 30c7e93..5625841 100644
--- a/tempest/testboto.py
+++ b/tempest/testboto.py
@@ -23,10 +23,9 @@
 from boto import ec2
 from boto import exception
 from boto import s3
-import testresources
-import testtools
 
 from tempest import exceptions
+import tempest.test
 import tempest.tests.boto
 from tempest.tests.boto.utils.wait import re_search_wait
 from tempest.tests.boto.utils.wait import state_wait
@@ -119,9 +118,7 @@
     return string + ")"
 
 
-class BotoTestCase(testtools.testcase.WithAttributes,
-                   testtools.TestCase,
-                   testresources.ResourcedTestCase):
+class BotoTestCase(tempest.test.BaseTestCase):
     """Recommended to use as base class for boto related test."""
 
     conclusion = tempest.tests.boto.generic_setup_package()
diff --git a/tempest/tests/boto/test_ec2_instance_run.py b/tempest/tests/boto/test_ec2_instance_run.py
index b0a7fcd..6b61c11 100644
--- a/tempest/tests/boto/test_ec2_instance_run.py
+++ b/tempest/tests/boto/test_ec2_instance_run.py
@@ -45,8 +45,8 @@
         cls.os = clients.Manager()
         cls.s3_client = cls.os.s3_client
         cls.ec2_client = cls.os.ec2api_client
-        config = cls.os.config
         cls.zone = cls.ec2_client.get_good_zone()
+        config = cls.config
         cls.materials_path = config.boto.s3_materials_path
         ami_manifest = config.boto.ami_manifest
         aki_manifest = config.boto.aki_manifest
diff --git a/tempest/tests/boto/test_s3_buckets.py b/tempest/tests/boto/test_s3_buckets.py
index a4d1927..0a05ae0 100644
--- a/tempest/tests/boto/test_s3_buckets.py
+++ b/tempest/tests/boto/test_s3_buckets.py
@@ -31,7 +31,6 @@
         super(S3BucketsTest, cls).setUpClass()
         cls.os = clients.Manager()
         cls.client = cls.os.s3_client
-        cls.config = cls.os.config
 
     @testtools.skip("Skipped until the Bug #1076965 is resolved")
     @attr(type='smoke')
diff --git a/tempest/tests/boto/test_s3_ec2_images.py b/tempest/tests/boto/test_s3_ec2_images.py
index 0f7628b..1088b00 100644
--- a/tempest/tests/boto/test_s3_ec2_images.py
+++ b/tempest/tests/boto/test_s3_ec2_images.py
@@ -40,7 +40,7 @@
         cls.os = clients.Manager()
         cls.s3_client = cls.os.s3_client
         cls.images_client = cls.os.ec2api_client
-        config = cls.os.config
+        config = cls.config
         cls.materials_path = config.boto.s3_materials_path
         cls.ami_manifest = config.boto.ami_manifest
         cls.aki_manifest = config.boto.aki_manifest
diff --git a/tempest/tests/boto/test_s3_objects.py b/tempest/tests/boto/test_s3_objects.py
index 8334b07..d50dc45 100644
--- a/tempest/tests/boto/test_s3_objects.py
+++ b/tempest/tests/boto/test_s3_objects.py
@@ -34,7 +34,6 @@
         super(S3BucketsTest, cls).setUpClass()
         cls.os = clients.Manager()
         cls.client = cls.os.s3_client
-        cls.config = cls.os.config
 
     @testtools.skip("Skipped until the Bug #1076534 is resolved")
     @attr(type='smoke')
diff --git a/tempest/tests/compute/base.py b/tempest/tests/compute/base.py
index b1ed5b5..2e5b4fe 100644
--- a/tempest/tests/compute/base.py
+++ b/tempest/tests/compute/base.py
@@ -18,29 +18,23 @@
 import logging
 import time
 
-import testresources
-import testtools
-
 from tempest import clients
 from tempest.common.utils.data_utils import rand_name
-from tempest import config
 from tempest import exceptions
+import tempest.test
 from tempest.tests import compute
 
 
 LOG = logging.getLogger(__name__)
 
 
-class BaseComputeTest(testtools.testcase.WithAttributes,
-                      testtools.TestCase,
-                      testresources.ResourcedTestCase):
+class BaseComputeTest(tempest.test.BaseTestCase):
     """Base test case class for all Compute API tests."""
 
     conclusion = compute.generic_setup_package()
 
     @classmethod
     def setUpClass(cls):
-        cls.config = config.TempestConfig()
         cls.isolated_creds = []
 
         if cls.config.compute.allow_tenant_isolation:
@@ -229,7 +223,6 @@
 
 
 class BaseComputeAdminTest(BaseComputeTest):
-
     """Base test case class for all Compute Admin API tests."""
 
     @classmethod
diff --git a/tempest/tests/identity/base.py b/tempest/tests/identity/base.py
index fbff88f..2c4162c 100644
--- a/tempest/tests/identity/base.py
+++ b/tempest/tests/identity/base.py
@@ -15,14 +15,13 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-import testtools
 
 from tempest import clients
 from tempest.common.utils.data_utils import rand_name
+import tempest.test
 
 
-class BaseIdAdminTest(testtools.testcase.WithAttributes,
-                      testtools.TestCase):
+class BaseIdAdminTest(tempest.test.BaseTestCase):
 
     @classmethod
     def setUpClass(cls):
diff --git a/tempest/tests/image/test_images.py b/tempest/tests/image/test_images.py
index 511f8b0..6ac852e 100644
--- a/tempest/tests/image/test_images.py
+++ b/tempest/tests/image/test_images.py
@@ -18,7 +18,7 @@
 import cStringIO as StringIO
 import random
 
-import testtools
+import tempest.test
 
 from tempest.test import attr
 
@@ -27,8 +27,7 @@
 from tempest import exceptions
 
 
-class CreateRegisterImagesTest(testtools.testcase.WithAttributes,
-                               testtools.TestCase):
+class CreateRegisterImagesTest(tempest.test.BaseTestCase):
 
     """
     Here we test the registration and creation of images
@@ -108,8 +107,7 @@
         self.assertEqual('active', body.get('status'))
 
 
-class ListImagesTest(testtools.testcase.WithAttributes,
-                     testtools.TestCase):
+class ListImagesTest(tempest.test.BaseTestCase):
 
     """
     Here we test the listing of image information
diff --git a/tempest/tests/network/base.py b/tempest/tests/network/base.py
index 8606079..4cc8b29 100644
--- a/tempest/tests/network/base.py
+++ b/tempest/tests/network/base.py
@@ -15,28 +15,25 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-import testtools
 
 from tempest import clients
 from tempest.common.utils.data_utils import rand_name
 from tempest import exceptions
+import tempest.test
 
 
-class BaseNetworkTest(testtools.testcase.WithAttributes,
-                      testtools.TestCase):
+class BaseNetworkTest(tempest.test.BaseTestCase):
 
     @classmethod
     def setUpClass(cls):
         os = clients.Manager()
         client = os.network_client
-        enabled = True
 
         # Validate that there is even an endpoint configured
         # for networks, and mark the attr for skipping if not
         try:
             client.list_networks()
         except exceptions.EndpointNotFound:
-            enabled = False
             skip_msg = "No OpenStack Network API endpoint"
             raise cls.skipException(skip_msg)
 
diff --git a/tempest/tests/object_storage/base.py b/tempest/tests/object_storage/base.py
index 2492d8b..5bfe1a3 100644
--- a/tempest/tests/object_storage/base.py
+++ b/tempest/tests/object_storage/base.py
@@ -15,15 +15,14 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-import testtools
 
 from tempest import clients
 from tempest import exceptions
+import tempest.test
 from tempest.tests.identity.base import DataGenerator
 
 
-class BaseObjectTest(testtools.testcase.WithAttributes,
-                     testtools.TestCase):
+class BaseObjectTest(tempest.test.BaseTestCase):
 
     @classmethod
     def setUpClass(cls):
@@ -31,7 +30,6 @@
         cls.object_client = cls.os.object_client
         cls.container_client = cls.os.container_client
         cls.account_client = cls.os.account_client
-        cls.config = cls.os.config
         cls.custom_object_client = cls.os.custom_object_client
         cls.os_admin = clients.AdminManager()
         cls.token_client = cls.os_admin.token_client
diff --git a/tempest/tests/volume/base.py b/tempest/tests/volume/base.py
index 4ddd670..00e8668 100644
--- a/tempest/tests/volume/base.py
+++ b/tempest/tests/volume/base.py
@@ -18,24 +18,20 @@
 import logging
 import time
 
-import testtools
-
 from tempest import clients
 from tempest.common.utils.data_utils import rand_name
-from tempest import config
 from tempest import exceptions
+import tempest.test
 
 LOG = logging.getLogger(__name__)
 
 
-class BaseVolumeTest(testtools.testcase.WithAttributes,
-                     testtools.TestCase):
+class BaseVolumeTest(tempest.test.BaseTestCase):
 
     """Base test case class for all Cinder API tests."""
 
     @classmethod
     def setUpClass(cls):
-        cls.config = config.TempestConfig()
         cls.isolated_creds = []
 
         if cls.config.compute.allow_tenant_isolation:
diff --git a/tempest/whitebox.py b/tempest/whitebox.py
index d5fa023..bfcc373 100644
--- a/tempest/whitebox.py
+++ b/tempest/whitebox.py
@@ -89,18 +89,18 @@
         # NOTE(jaypipes): Tests often add things in a particular order
         # so we destroy resources in the reverse order in which resources
         # are added to the test class object
-        if not cls.resources:
+        if not cls.os_resources:
             return
-        thing = cls.resources.pop()
+        thing = cls.os_resources.pop()
         while True:
             LOG.debug("Deleting %r from shared resources of %s" %
                       (thing, cls.__name__))
             # Resources in novaclient all have a delete() method
             # which destroys the resource...
             thing.delete()
-            if not cls.resources:
+            if not cls.os_resources:
                 return
-            thing = cls.resources.pop()
+            thing = cls.os_resources.pop()
 
     @classmethod
     def create_server(cls, image_id=None):