diff options
Diffstat (limited to 'nova')
| -rw-r--r-- | nova/test.py | 9 | ||||
| -rw-r--r-- | nova/tests/api/ec2/test_cloud.py | 3 | ||||
| -rw-r--r-- | nova/tests/conductor/test_conductor.py | 8 | ||||
| -rw-r--r-- | nova/tests/hyperv/basetestcase.py | 11 | ||||
| -rw-r--r-- | nova/tests/image/test_s3.py | 3 | ||||
| -rw-r--r-- | nova/tests/integrated/test_api_samples.py | 2 | ||||
| -rw-r--r-- | nova/tests/integrated/test_extensions.py | 2 | ||||
| -rw-r--r-- | nova/tests/test_api.py | 2 | ||||
| -rw-r--r-- | nova/tests/test_imagebackend.py | 8 | ||||
| -rw-r--r-- | nova/tests/test_virt_drivers.py | 10 | ||||
| -rw-r--r-- | nova/tests/test_xenapi.py | 2 |
11 files changed, 44 insertions, 16 deletions
diff --git a/nova/test.py b/nova/test.py index 89db4999a..15f0ff122 100644 --- a/nova/test.py +++ b/nova/test.py @@ -191,6 +191,15 @@ class TestCase(testtools.TestCase): self.useFixture(fixtures.NestedTempfile()) self.useFixture(fixtures.TempHomeDir()) + if (os.environ.get('OS_STDOUT_NOCAPTURE') != 'True' and + os.environ.get('OS_STDOUT_NOCAPTURE') != '1'): + stdout = self.useFixture(fixtures.DetailStream('stdout')).stream + self.useFixture(fixtures.MonkeyPatch('sys.stdout', stdout)) + if (os.environ.get('OS_STDERR_NOCAPTURE') != 'True' and + os.environ.get('OS_STDERR_NOCAPTURE') != '1'): + stderr = self.useFixture(fixtures.DetailStream('stderr')).stream + self.useFixture(fixtures.MonkeyPatch('sys.stderr', stderr)) + self.log_fixture = self.useFixture(fixtures.FakeLogger('nova')) self.useFixture(conf_fixture.ConfFixture(CONF)) diff --git a/nova/tests/api/ec2/test_cloud.py b/nova/tests/api/ec2/test_cloud.py index 0a694bbb7..831143326 100644 --- a/nova/tests/api/ec2/test_cloud.py +++ b/nova/tests/api/ec2/test_cloud.py @@ -25,6 +25,8 @@ import os import string import tempfile +import fixtures + from nova.api.ec2 import cloud from nova.api.ec2 import ec2utils from nova.api.ec2 import inst_state @@ -101,6 +103,7 @@ class CloudTestCase(test.TestCase): super(CloudTestCase, self).setUp() self.flags(compute_driver='nova.virt.fake.FakeDriver', volume_api_class='nova.tests.fake_volume.API') + self.useFixture(fixtures.FakeLogger('boto')) def fake_show(meh, context, id): return {'id': id, diff --git a/nova/tests/conductor/test_conductor.py b/nova/tests/conductor/test_conductor.py index 4aec358b8..bbdefdb7f 100644 --- a/nova/tests/conductor/test_conductor.py +++ b/nova/tests/conductor/test_conductor.py @@ -36,7 +36,7 @@ from nova import test FAKE_IMAGE_REF = 'fake-image-ref' -class _BaseTestCase(test.TestCase): +class _BaseTestCase(object): def setUp(self): super(_BaseTestCase, self).setUp() self.db = None @@ -223,7 +223,7 @@ class _BaseTestCase(test.TestCase): self.assertEqual(port, backdoor_port) -class ConductorTestCase(_BaseTestCase): +class ConductorTestCase(_BaseTestCase, test.TestCase): """Conductor Manager Tests""" def setUp(self): super(ConductorTestCase, self).setUp() @@ -231,7 +231,7 @@ class ConductorTestCase(_BaseTestCase): self.stub_out_client_exceptions() -class ConductorRPCAPITestCase(_BaseTestCase): +class ConductorRPCAPITestCase(_BaseTestCase, test.TestCase): """Conductor RPC API Tests""" def setUp(self): super(ConductorRPCAPITestCase, self).setUp() @@ -240,7 +240,7 @@ class ConductorRPCAPITestCase(_BaseTestCase): self.conductor = conductor_rpcapi.ConductorAPI() -class ConductorAPITestCase(_BaseTestCase): +class ConductorAPITestCase(_BaseTestCase, test.TestCase): """Conductor API Tests""" def setUp(self): super(ConductorAPITestCase, self).setUp() diff --git a/nova/tests/hyperv/basetestcase.py b/nova/tests/hyperv/basetestcase.py index 4458dbd9d..c4f6cf95f 100644 --- a/nova/tests/hyperv/basetestcase.py +++ b/nova/tests/hyperv/basetestcase.py @@ -43,9 +43,16 @@ class BaseTestCase(test.TestCase): def tearDown(self): super(BaseTestCase, self).tearDown() - has_errors = len([test for (test, msgs) in self._currentResult.errors + # python-subunit will wrap test results with a decorator. + # Need to access the decorated member of results to get the + # actual test result when using python-subunit. + if hasattr(self._currentResult, 'decorated'): + result = self._currentResult.decorated + else: + result = self._currentResult + has_errors = len([test for (test, msgs) in result.errors if test.id() == self.id()]) > 0 - failed = len([test for (test, msgs) in self._currentResult.failures + failed = len([test for (test, msgs) in result.failures if test.id() == self.id()]) > 0 if not has_errors and not failed: diff --git a/nova/tests/image/test_s3.py b/nova/tests/image/test_s3.py index 3c92ffb2e..4f8790cc7 100644 --- a/nova/tests/image/test_s3.py +++ b/nova/tests/image/test_s3.py @@ -21,6 +21,8 @@ import mox import os import tempfile +import fixtures + from nova import context import nova.db.api from nova import exception @@ -83,6 +85,7 @@ class TestS3ImageService(test.TestCase): def setUp(self): super(TestS3ImageService, self).setUp() self.context = context.RequestContext(None, None) + self.useFixture(fixtures.FakeLogger('boto')) # set up one fixture to test shows, should have id '1' nova.db.api.s3_image_create(self.context, diff --git a/nova/tests/integrated/test_api_samples.py b/nova/tests/integrated/test_api_samples.py index 4f73f6bfe..fb9de8072 100644 --- a/nova/tests/integrated/test_api_samples.py +++ b/nova/tests/integrated/test_api_samples.py @@ -22,6 +22,8 @@ import uuid from lxml import etree +# Import extensions to pull in osapi_compute_extension CONF option used below. +from nova.api.openstack.compute import extensions from nova.cloudpipe.pipelib import CloudPipe from nova.compute import api from nova import context diff --git a/nova/tests/integrated/test_extensions.py b/nova/tests/integrated/test_extensions.py index 61e4e32d0..968379a6c 100644 --- a/nova/tests/integrated/test_extensions.py +++ b/nova/tests/integrated/test_extensions.py @@ -15,6 +15,8 @@ # License for the specific language governing permissions and limitations # under the License. +# Import extensions to pull in osapi_compute_extension CONF option used below. +from nova.api.openstack.compute import extensions from nova.openstack.common import cfg from nova.openstack.common.log import logging from nova.tests.integrated import integrated_helpers diff --git a/nova/tests/test_api.py b/nova/tests/test_api.py index cf6e1de90..163afda7d 100644 --- a/nova/tests/test_api.py +++ b/nova/tests/test_api.py @@ -29,6 +29,7 @@ try: from boto.connection import HTTPResponse except ImportError: from httplib import HTTPResponse +import fixtures import webob from nova.api import auth @@ -221,6 +222,7 @@ class ApiEc2TestCase(test.TestCase): self.app = auth.InjectContext(ctxt, ec2.FaultWrapper( ec2.RequestLogging(ec2.Requestify(ec2.Authorizer(ec2.Executor() ), 'nova.api.ec2.cloud.CloudController')))) + self.useFixture(fixtures.FakeLogger('boto')) def expect_http(self, host=None, is_secure=False, api_version=None): """Returns a new EC2 connection""" diff --git a/nova/tests/test_imagebackend.py b/nova/tests/test_imagebackend.py index eca2267a6..c15259066 100644 --- a/nova/tests/test_imagebackend.py +++ b/nova/tests/test_imagebackend.py @@ -27,7 +27,7 @@ from nova.virt.libvirt import imagebackend CONF = cfg.CONF -class _ImageTestCase(test.TestCase): +class _ImageTestCase(object): INSTANCES_PATH = '/fake' def mock_create_image(self, image): @@ -111,7 +111,7 @@ class _ImageTestCase(test.TestCase): self.mox.VerifyAll() -class RawTestCase(_ImageTestCase): +class RawTestCase(_ImageTestCase, test.TestCase): SIZE = 1024 @@ -161,7 +161,7 @@ class RawTestCase(_ImageTestCase): self.mox.VerifyAll() -class Qcow2TestCase(_ImageTestCase): +class Qcow2TestCase(_ImageTestCase, test.TestCase): SIZE = 1024 * 1024 * 1024 def setUp(self): @@ -224,7 +224,7 @@ class Qcow2TestCase(_ImageTestCase): self.mox.VerifyAll() -class LvmTestCase(_ImageTestCase): +class LvmTestCase(_ImageTestCase, test.TestCase): VG = 'FakeVG' TEMPLATE_SIZE = 512 SIZE = 1024 diff --git a/nova/tests/test_virt_drivers.py b/nova/tests/test_virt_drivers.py index 563b3a44b..cd525d2a1 100644 --- a/nova/tests/test_virt_drivers.py +++ b/nova/tests/test_virt_drivers.py @@ -57,7 +57,7 @@ def catch_notimplementederror(f): return wrapped_func -class _FakeDriverBackendTestCase(test.TestCase): +class _FakeDriverBackendTestCase(object): def _setup_fakelibvirt(self): # So that the _supports_direct_io does the test based # on the current working directory, instead of the @@ -142,7 +142,7 @@ class _FakeDriverBackendTestCase(test.TestCase): super(_FakeDriverBackendTestCase, self).tearDown() -class VirtDriverLoaderTestCase(_FakeDriverBackendTestCase): +class VirtDriverLoaderTestCase(_FakeDriverBackendTestCase, test.TestCase): """Test that ComputeManager can successfully load both old style and new style drivers and end up with the correct final class""" @@ -532,19 +532,19 @@ class _VirtDriverTestCase(_FakeDriverBackendTestCase): self.connection.remove_from_aggregate(self.ctxt, 'aggregate', 'host') -class AbstractDriverTestCase(_VirtDriverTestCase): +class AbstractDriverTestCase(_VirtDriverTestCase, test.TestCase): def setUp(self): self.driver_module = "nova.virt.driver.ComputeDriver" super(AbstractDriverTestCase, self).setUp() -class FakeConnectionTestCase(_VirtDriverTestCase): +class FakeConnectionTestCase(_VirtDriverTestCase, test.TestCase): def setUp(self): self.driver_module = 'nova.virt.fake.FakeDriver' super(FakeConnectionTestCase, self).setUp() -class LibvirtConnTestCase(_VirtDriverTestCase): +class LibvirtConnTestCase(_VirtDriverTestCase, test.TestCase): def setUp(self): # Point _VirtDriverTestCase at the right module self.driver_module = 'nova.virt.libvirt.LibvirtDriver' diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py index 575b4c029..c49664aa8 100644 --- a/nova/tests/test_xenapi.py +++ b/nova/tests/test_xenapi.py @@ -339,8 +339,8 @@ class XenAPIVMTestCase(stubs.XenAPITestBase): self.stubs.Set(vm_utils, '_safe_copy_vdi', fake_safe_copy_vdi) def tearDown(self): - super(XenAPIVMTestCase, self).tearDown() fake_image.FakeImageService_reset() + super(XenAPIVMTestCase, self).tearDown() def test_init_host(self): session = xenapi_conn.XenAPISession('test_url', 'root', 'test_pass', |
