diff --git a/nova/tests/test_api.py b/nova/tests/test_api.py index d2710777..6e0a97c0 100644 --- a/nova/tests/test_api.py +++ b/nova/tests/test_api.py @@ -431,7 +431,7 @@ class ApiEc2TestCase(test.TestCase): group.authorize(*args) except boto_exc.EC2ResponseError as e: self.assertEqual(e.status, 400, 'Expected status to be 400') - self.assertIn(message, e.error_message, e.error_message) + self.assertIn(message, e.error_message) else: raise self.failureException, 'EC2ResponseError not raised' diff --git a/nova/tests/test_migrations.py b/nova/tests/test_migrations.py index 58acfff7..5ec91ca1 100644 --- a/nova/tests/test_migrations.py +++ b/nova/tests/test_migrations.py @@ -217,11 +217,12 @@ class TestMigrations(test.TestCase): if _is_mysql_avail(user="openstack_cifail"): self.fail("Shouldn't have connected") - @test.skip_unless(_have_mysql(), "mysql not available") def test_mysql_innodb(self): """ Test that table creation on mysql only builds InnoDB tables """ + if not _have_mysql(): + self.skipTest("mysql not available") # add this to the global lists to make reset work with it, it's removed # automaticaly in tearDown so no need to clean it up here. connect_string = _mysql_get_connect_string() diff --git a/nova/tests/test_nova_rootwrap.py b/nova/tests/test_nova_rootwrap.py index e9a48dbb..f67f2f56 100644 --- a/nova/tests/test_nova_rootwrap.py +++ b/nova/tests/test_nova_rootwrap.py @@ -63,9 +63,9 @@ class RootwrapTestCase(test.TestCase): self.assertEqual(env.get('FLAGFILE'), 'A') self.assertEqual(env.get('NETWORK_ID'), 'foobar') - @test.skip_if(not os.path.exists("/proc/%d" % os.getpid()), - "Test requires /proc filesystem (procfs)") def test_KillFilter(self): + if not os.path.exists("/proc/%d" % os.getpid()): + self.skipTest("Test requires /proc filesystem (procfs)") p = subprocess.Popen(["cat"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) diff --git a/nova/tests/test_skip_examples.py b/nova/tests/test_skip_examples.py deleted file mode 100644 index 8ca20344..00000000 --- a/nova/tests/test_skip_examples.py +++ /dev/null @@ -1,47 +0,0 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 - -# Copyright 2010 United States Government as represented by the -# Administrator of the National Aeronautics and Space Administration. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from nova import test - - -class ExampleSkipTestCase(test.TestCase): - test_counter = 0 - - @test.skip_test("Example usage of @test.skip_test()") - def test_skip_test_example(self): - self.fail("skip_test failed to work properly.") - - @test.skip_if(True, "Example usage of @test.skip_if()") - def test_skip_if_example(self): - self.fail("skip_if failed to work properly.") - - @test.skip_unless(False, "Example usage of @test.skip_unless()") - def test_skip_unless_example(self): - self.fail("skip_unless failed to work properly.") - - @test.skip_if(False, "This test case should never be skipped.") - def test_001_increase_test_counter(self): - ExampleSkipTestCase.test_counter += 1 - - @test.skip_unless(True, "This test case should never be skipped.") - def test_002_increase_test_counter(self): - ExampleSkipTestCase.test_counter += 1 - - def test_003_verify_test_counter(self): - self.assertEquals(ExampleSkipTestCase.test_counter, 2, - "Tests were not skipped appropriately") diff --git a/nova/tests/test_virt.py b/nova/tests/test_virt.py index 166e87d8..16775054 100644 --- a/nova/tests/test_virt.py +++ b/nova/tests/test_virt.py @@ -16,11 +16,11 @@ # under the License. import os -import platform from nova import exception from nova import flags from nova import test +from nova import tests from nova import utils from nova.virt.disk import api as disk_api from nova.virt import driver @@ -166,27 +166,31 @@ class TestVirtDiskPaths(test.TestCase): self.stubs.Set(utils, 'execute', nonroot_execute) - @test.skip_unless(platform.mac_ver()[0] == '', "Unable to test on OSX") def test_check_safe_path(self): + if tests.utils.is_osx(): + self.skipTest("Unable to test on OSX") ret = disk_api._join_and_check_path_within_fs('/foo', 'etc', 'something.conf') self.assertEquals(ret, '/foo/etc/something.conf') - @test.skip_unless(platform.mac_ver()[0] == '', "Unable to test on OSX") def test_check_unsafe_path(self): + if tests.utils.is_osx(): + self.skipTest("Unable to test on OSX") self.assertRaises(exception.Invalid, disk_api._join_and_check_path_within_fs, '/foo', 'etc/../../../something.conf') - @test.skip_unless(platform.mac_ver()[0] == '', "Unable to test on OSX") def test_inject_files_with_bad_path(self): + if tests.utils.is_osx(): + self.skipTest("Unable to test on OSX") self.assertRaises(exception.Invalid, disk_api._inject_file_into_fs, '/tmp', '/etc/../../../../etc/passwd', 'hax') - @test.skip_unless(platform.mac_ver()[0] == '', "Unable to test on OSX") def test_inject_metadata(self): + if tests.utils.is_osx(): + self.skipTest("Unable to test on OSX") with utils.tempdir() as tmpdir: meta_objs = [{"key": "foo", "value": "bar"}] metadata = {"foo": "bar"} diff --git a/nova/tests/test_virt_drivers.py b/nova/tests/test_virt_drivers.py index e34cf0d0..ec87c911 100644 --- a/nova/tests/test_virt_drivers.py +++ b/nova/tests/test_virt_drivers.py @@ -537,8 +537,7 @@ class LibvirtConnTestCase(_VirtDriverTestCase): self.flags(libvirt_wait_soft_reboot_seconds=0) self.test_reboot() - @test.skip_test("Test nothing, but this method " - "needed to override superclass.") def test_migrate_disk_and_power_off(self): # there is lack of fake stuff to execute this method. so pass. - pass + self.skipTest("Test nothing, but this method" + " needed to override superclass.")