diff --git a/.testr.conf b/.testr.conf new file mode 100644 index 00000000..fd944234 --- /dev/null +++ b/.testr.conf @@ -0,0 +1,4 @@ +[DEFAULT] +test_command=${PYTHON:-python} -m subunit.run discover -t ./ ./nova/tests $LISTOPT $IDOPTION +test_id_option=--load-list $IDFILE +test_list_option=--list diff --git a/nova/tests/hyperv/basetestcase.py b/nova/tests/hyperv/basetestcase.py index 4458dbd9..c4f6cf95 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/test_api.py b/nova/tests/test_api.py index cf6e1de9..163afda7 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 eca2267a..c1525906 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 563b3a44..cd525d2a 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 575b4c02..c49664aa 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',