diff --git a/neutron/tests/functional/api/test_policies.py b/neutron/tests/functional/api/test_policies.py index 6826aabd34c..9ad485126e2 100644 --- a/neutron/tests/functional/api/test_policies.py +++ b/neutron/tests/functional/api/test_policies.py @@ -42,6 +42,7 @@ class APIPolicyTestCase(base.BaseTestCase): self.extension_path = os.path.abspath(os.path.join( TEST_PATH, "../../../extensions")) policy.reset() + self.addCleanup(policy.reset) def _network_definition(self): return {'name': 'test_network', @@ -85,7 +86,3 @@ class APIPolicyTestCase(base.BaseTestCase): tenant_context = context.Context('test_user', 'test_tenant_id', False) self.assertTrue(self._check_external_router_policy(admin_context)) self.assertTrue(self._check_external_router_policy(tenant_context)) - - def tearDown(self): - policy.reset() - super(APIPolicyTestCase, self).tearDown() diff --git a/neutron/tests/functional/pecan_wsgi/__init__.py b/neutron/tests/functional/pecan_wsgi/__init__.py index 21264f1ea05..efc196e4d80 100644 --- a/neutron/tests/functional/pecan_wsgi/__init__.py +++ b/neutron/tests/functional/pecan_wsgi/__init__.py @@ -35,6 +35,4 @@ class FunctionalTest(unittest2.TestCase): os.path.dirname(__file__), 'config.py' )) - - def tearDown(self): - set_config({}, overwrite=True) + self.addCleanup(set_config, {}, overwrite=True) diff --git a/neutron/tests/tempest/api/test_dhcp_ipv6.py b/neutron/tests/tempest/api/test_dhcp_ipv6.py index bf45825c0a8..b1a33612fc9 100644 --- a/neutron/tests/tempest/api/test_dhcp_ipv6.py +++ b/neutron/tests/tempest/api/test_dhcp_ipv6.py @@ -27,6 +27,10 @@ CONF = config.CONF class NetworksTestDHCPv6(base.BaseNetworkTest): _ip_version = 6 + def setUp(self): + super(NetworksTestDHCPv6, self).setUp() + self.addCleanup(self._clean_network) + @classmethod def skip_checks(cls): msg = None @@ -92,7 +96,3 @@ class NetworksTestDHCPv6(base.BaseNetworkTest): self.network, fixed_ips=[{'subnet_id': subnet['id'], 'ip_address': ip}]) - - def tearDown(self): - self._clean_network() - super(NetworksTestDHCPv6, self).tearDown() diff --git a/neutron/tests/unit/api/v2/test_base.py b/neutron/tests/unit/api/v2/test_base.py index a627c39f58e..2382066f1a7 100644 --- a/neutron/tests/unit/api/v2/test_base.py +++ b/neutron/tests/unit/api/v2/test_base.py @@ -1195,9 +1195,6 @@ class SubresourceTest(base.BaseTestCase): member=member_actions) self.api = webtest.TestApp(api) - def tearDown(self): - super(SubresourceTest, self).tearDown() - def test_index_sub_resource(self): instance = self.plugin.return_value @@ -1494,11 +1491,6 @@ class ExtensionTestCase(base.BaseTestCase): cfg.CONF.set_override('quota_driver', 'neutron.quota.ConfDriver', group='QUOTAS') - def tearDown(self): - super(ExtensionTestCase, self).tearDown() - self.api = None - self.plugin = None - def test_extended_create(self): net_id = _uuid() tenant_id = _uuid() diff --git a/neutron/tests/unit/db/test_db_base_plugin_v2.py b/neutron/tests/unit/db/test_db_base_plugin_v2.py index 33b4c5fa96c..255b0246f7c 100644 --- a/neutron/tests/unit/db/test_db_base_plugin_v2.py +++ b/neutron/tests/unit/db/test_db_base_plugin_v2.py @@ -163,15 +163,6 @@ class NeutronDbPluginV2TestCase(testlib_api.WebTestCase): if ext_mgr: self.ext_api = test_extensions.setup_extensions_middleware(ext_mgr) - def tearDown(self): - self.api = None - self._deserializers = None - self._skip_native_bulk = None - self._skip_native_pagination = None - self._skip_native_sortin = None - self.ext_api = None - super(NeutronDbPluginV2TestCase, self).tearDown() - def setup_config(self): # Create the default configurations args = ['--config-file', base.etcdir('neutron.conf')] diff --git a/neutron/tests/unit/extensions/test_l3_ext_gw_mode.py b/neutron/tests/unit/extensions/test_l3_ext_gw_mode.py index 561c5c9881a..303db1f888f 100644 --- a/neutron/tests/unit/extensions/test_l3_ext_gw_mode.py +++ b/neutron/tests/unit/extensions/test_l3_ext_gw_mode.py @@ -384,9 +384,6 @@ class ExtGwModeIntTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase, def restore_l3_attribute_map(self): l3.RESOURCE_ATTRIBUTE_MAP = self._l3_attribute_map_bk - def tearDown(self): - super(ExtGwModeIntTestCase, self).tearDown() - def _set_router_external_gateway(self, router_id, network_id, snat_enabled=None, expected_code=exc.HTTPOk.code, diff --git a/neutron/tests/unit/extensions/test_portsecurity.py b/neutron/tests/unit/extensions/test_portsecurity.py index 07821caab1e..9ccb3a2370a 100644 --- a/neutron/tests/unit/extensions/test_portsecurity.py +++ b/neutron/tests/unit/extensions/test_portsecurity.py @@ -45,10 +45,6 @@ class PortSecurityTestCase( self._skip_security_group = ('security-group' not in plugin_obj.supported_extension_aliases) - def tearDown(self): - super(PortSecurityTestCase, self).tearDown() - self._skip_security_group = None - class PortSecurityTestPlugin(db_base_plugin_v2.NeutronDbPluginV2, securitygroups_db.SecurityGroupDbMixin, diff --git a/neutron/tests/unit/extensions/test_quotasv2.py b/neutron/tests/unit/extensions/test_quotasv2.py index 4d1adafbde1..ec8db310576 100644 --- a/neutron/tests/unit/extensions/test_quotasv2.py +++ b/neutron/tests/unit/extensions/test_quotasv2.py @@ -70,11 +70,6 @@ class QuotaExtensionTestCase(testlib_api.WebTestCase): # resources are registered router.APIRouter() - def tearDown(self): - self.api = None - self.plugin = None - super(QuotaExtensionTestCase, self).tearDown() - def _test_quota_default_values(self, expected_values): tenant_id = 'tenant_id1' env = {'neutron.context': context.Context('', tenant_id)} diff --git a/neutron/tests/unit/plugins/ml2/extensions/test_dns_integration.py b/neutron/tests/unit/plugins/ml2/extensions/test_dns_integration.py index 0c9f855dbd2..a47a2afd402 100644 --- a/neutron/tests/unit/plugins/ml2/extensions/test_dns_integration.py +++ b/neutron/tests/unit/plugins/ml2/extensions/test_dns_integration.py @@ -625,9 +625,12 @@ class TestDesignateClientKeystoneV3(testtools.TestCase): super(TestDesignateClientKeystoneV3, self).setUp() # Register the Password auth plugin options, # so we can use CONF.set_override - config.cfg.CONF.register_opts( - loading.get_auth_plugin_conf_options('password'), - group='designate') + password_option = loading.get_auth_plugin_conf_options('password') + config.cfg.CONF.register_opts(password_option, group='designate') + self.addCleanup( + config.cfg.CONF.unregister_opts, + password_option, group='designate') + config.cfg.CONF.set_override('url', self.TEST_URL, group='designate') @@ -660,12 +663,6 @@ class TestDesignateClientKeystoneV3(testtools.TestCase): self.password = ( mock.patch.object(driver.password, 'Password').start()) - def tearDown(self): - super(TestDesignateClientKeystoneV3, self).tearDown() - config.cfg.CONF.unregister_opts( - loading.get_auth_plugin_conf_options('password'), - group='designate') - def test_insecure_client(self): config.cfg.CONF.set_override('insecure', True, diff --git a/neutron/tests/unit/plugins/ml2/test_security_group.py b/neutron/tests/unit/plugins/ml2/test_security_group.py index c0cdb7c1d85..9662bfb4dfc 100644 --- a/neutron/tests/unit/plugins/ml2/test_security_group.py +++ b/neutron/tests/unit/plugins/ml2/test_security_group.py @@ -44,9 +44,6 @@ class Ml2SecurityGroupsTestCase(test_sg.SecurityGroupDBTestCase): self.useFixture(tools.AttributeMapMemento()) super(Ml2SecurityGroupsTestCase, self).setUp('ml2') - def tearDown(self): - super(Ml2SecurityGroupsTestCase, self).tearDown() - class TestMl2SecurityGroups(Ml2SecurityGroupsTestCase, test_sg.TestSecurityGroups,