Browse Source

Remove unnecessary setUp and tearDown

setUp and tearDown will be automatically called around each
testcase, so this is to remove setUp and tearDown that doing
nothing additional than super to keep code clean.

Change-Id: I8b6943602419d3f360991721d90b61888b55ea60
changes/86/373586/2
zhufl 5 years ago
parent
commit
bc3c16a8e5
  1. 3
      heat/tests/api/cfn/test_api_cfn_v1.py
  2. 3
      heat/tests/api/cloudwatch/test_api_cloudwatch.py
  3. 6
      heat/tests/api/test_wsgi.py
  4. 3
      heat/tests/autoscaling/test_heat_scaling_group.py
  5. 3
      heat/tests/autoscaling/test_heat_scaling_policy.py
  6. 3
      heat/tests/autoscaling/test_launch_config.py
  7. 6
      heat/tests/autoscaling/test_scaling_group.py
  8. 6
      heat/tests/autoscaling/test_scaling_policy.py
  9. 9
      heat/tests/aws/test_waitcondition.py
  10. 3
      heat/tests/convergence/test_converge.py
  11. 3
      heat/tests/db/test_sqlalchemy_api.py
  12. 3
      heat/tests/db/test_utils.py
  13. 3
      heat/tests/engine/test_engine_worker.py
  14. 3
      heat/tests/openstack/heat/test_restarter.py
  15. 3
      heat/tests/test_dbinstance.py
  16. 3
      heat/tests/test_engine_service.py
  17. 3
      heat/tests/test_event.py
  18. 3
      heat/tests/test_lifecycle_plugin_utils.py
  19. 3
      heat/tests/test_timeutils.py
  20. 3
      heat_integrationtests/functional/test_conditions.py
  21. 6
      heat_integrationtests/functional/test_create_update.py
  22. 3
      heat_integrationtests/functional/test_create_update_neutron_subnet.py
  23. 3
      heat_integrationtests/functional/test_default_parameters.py
  24. 3
      heat_integrationtests/functional/test_encrypted_parameter.py
  25. 6
      heat_integrationtests/functional/test_heat_autoscaling.py
  26. 12
      heat_integrationtests/functional/test_resource_group.py
  27. 3
      heat_integrationtests/functional/test_stack_events.py
  28. 3
      heat_integrationtests/functional/test_swiftsignal_update.py
  29. 21
      heat_integrationtests/functional/test_template_resource.py
  30. 3
      heat_integrationtests/functional/test_templates.py
  31. 3
      heat_integrationtests/functional/test_unicode_template.py

3
heat/tests/api/cfn/test_api_cfn_v1.py

@ -62,9 +62,6 @@ class CfnStackControllerTest(common.HeatTestCase):
self.assertRaises(
exception.HeatInvalidActionError, self.controller.default, None)
def tearDown(self):
super(CfnStackControllerTest, self).tearDown()
def _dummy_GET_request(self, params=None):
# Mangle the params dict into a query string
params = params or {}

3
heat/tests/api/cloudwatch/test_api_cloudwatch.py

@ -50,9 +50,6 @@ class WatchControllerTest(common.HeatTestCase):
'deny_stack_user.json')
self.addCleanup(self.m.VerifyAll)
def tearDown(self):
super(WatchControllerTest, self).tearDown()
def _dummy_GET_request(self, params=None):
# Mangle the params dict into a query string
params = params or {}

6
heat/tests/api/test_wsgi.py

@ -32,9 +32,6 @@ from heat.tests import common
class RequestTest(common.HeatTestCase):
def setUp(self):
super(RequestTest, self).setUp()
def test_content_type_missing(self):
request = wsgi.Request.blank('/tests/123')
self.assertRaises(exception.InvalidContentType,
@ -106,9 +103,6 @@ class RequestTest(common.HeatTestCase):
class ResourceTest(common.HeatTestCase):
def setUp(self):
super(ResourceTest, self).setUp()
def test_get_action_args(self):
env = {
'wsgiorg.routing_args': [

3
heat/tests/autoscaling/test_heat_scaling_group.py

@ -84,9 +84,6 @@ class TestInitialGroupSize(common.HeatTestCase):
('14n', dict(mins=1, maxs=4, desired=None, expected=1)),
]
def setUp(self):
super(TestInitialGroupSize, self).setUp()
def test_initial_size(self):
t = template_format.parse(inline_templates.as_heat_template)
properties = t['resources']['my-group']['properties']

3
heat/tests/autoscaling/test_heat_scaling_policy.py

@ -160,9 +160,6 @@ class TestAutoScalingPolicy(common.HeatTestCase):
class TestCooldownMixin(common.HeatTestCase):
def setUp(self):
super(TestCooldownMixin, self).setUp()
def create_scaling_policy(self, t, stack, resource_name):
rsrc = stack[resource_name]
self.assertIsNone(rsrc.validate())

3
heat/tests/autoscaling/test_launch_config.py

@ -25,9 +25,6 @@ from heat.tests import utils
class LaunchConfigurationTest(common.HeatTestCase):
def setUp(self):
super(LaunchConfigurationTest, self).setUp()
def validate_launch_config(self, stack, lc_name='LaunchConfig'):
# create the launch configuration resource
conf = stack[lc_name]

6
heat/tests/autoscaling/test_scaling_group.py

@ -33,9 +33,6 @@ as_template = inline_templates.as_template
class TestAutoScalingGroupValidation(common.HeatTestCase):
def setUp(self):
super(TestAutoScalingGroupValidation, self).setUp()
def validate_scaling_group(self, t, stack, resource_name):
# create the launch configuration resource
conf = stack['LaunchConfig']
@ -271,9 +268,6 @@ class TestInitialGroupSize(common.HeatTestCase):
('14n', dict(mins=1, maxs=4, desired=None, expected=1)),
]
def setUp(self):
super(TestInitialGroupSize, self).setUp()
def test_initial_size(self):
t = template_format.parse(as_template)
properties = t['Resources']['WebServerGroup']['Properties']

6
heat/tests/autoscaling/test_scaling_policy.py

@ -32,9 +32,6 @@ as_params = inline_templates.as_params
class TestAutoScalingPolicy(common.HeatTestCase):
def setUp(self):
super(TestAutoScalingPolicy, self).setUp()
def create_scaling_policy(self, t, stack, resource_name):
rsrc = stack[resource_name]
self.assertIsNone(rsrc.validate())
@ -174,9 +171,6 @@ class TestAutoScalingPolicy(common.HeatTestCase):
class TestCooldownMixin(common.HeatTestCase):
def setUp(self):
super(TestCooldownMixin, self).setUp()
def create_scaling_policy(self, t, stack, resource_name):
rsrc = stack[resource_name]
self.assertIsNone(rsrc.validate())

9
heat/tests/aws/test_waitcondition.py

@ -78,9 +78,6 @@ test_template_wc_count = '''
class WaitConditionTest(common.HeatTestCase):
def setUp(self):
super(WaitConditionTest, self).setUp()
def create_stack(self, stack_id=None,
template=test_template_waitcondition, params=None,
stub=True, stub_status=True):
@ -379,9 +376,6 @@ class WaitConditionTest(common.HeatTestCase):
class WaitConditionHandleTest(common.HeatTestCase):
def setUp(self):
super(WaitConditionHandleTest, self).setUp()
def create_stack(self, stack_name=None, stack_id=None):
temp = template_format.parse(test_template_waitcondition)
template = tmpl.Template(temp)
@ -559,9 +553,6 @@ class WaitConditionHandleTest(common.HeatTestCase):
class WaitConditionUpdateTest(common.HeatTestCase):
def setUp(self):
super(WaitConditionUpdateTest, self).setUp()
def create_stack(self, temp=None):
if temp is None:
temp = test_template_wc_count

3
heat/tests/convergence/test_converge.py

@ -35,9 +35,6 @@ class ScenarioTest(common.HeatTestCase):
po.side_effect = self.procs.worker.check_resource
cfg.CONF.set_default('convergence_engine', True)
def tearDown(self):
super(ScenarioTest, self).tearDown()
def test_scenario(self):
self.procs.clear()
runner = scenario.Scenario(self.name, self.path)

3
heat/tests/db/test_sqlalchemy_api.py

@ -80,9 +80,6 @@ class SqlAlchemyTest(common.HeatTestCase):
self.fc = fakes_nova.FakeClient()
self.ctx = utils.dummy_context()
def tearDown(self):
super(SqlAlchemyTest, self).tearDown()
def _mock_get_image_id_success(self, imageId_input, imageId):
self.m.StubOutWithMock(glance.GlanceClientPlugin,
'find_image_by_name_or_id')

3
heat/tests/db/test_utils.py

@ -35,9 +35,6 @@ class DBMigrationUtilsTest(common.HeatTestCase):
super(DBMigrationUtilsTest, self).setUp()
self.engine = utils.get_engine()
def tearDown(self):
super(DBMigrationUtilsTest, self).tearDown()
def test_clone_table_adds_or_deletes_columns(self):
meta = MetaData()
meta.bind = self.engine

3
heat/tests/engine/test_engine_worker.py

@ -27,9 +27,6 @@ from heat.tests import utils
class WorkerServiceTest(common.HeatTestCase):
def setUp(self):
super(WorkerServiceTest, self).setUp()
def test_make_sure_rpc_version(self):
self.assertEqual(
'1.3',

3
heat/tests/openstack/heat/test_restarter.py

@ -40,9 +40,6 @@ restarter_template = '''
class RestarterTest(common.HeatTestCase):
def setUp(self):
super(RestarterTest, self).setUp()
def create_restarter(self):
snippet = template_format.parse(restarter_template)
self.stack = utils.parse_stack(snippet)

3
heat/tests/test_dbinstance.py

@ -149,9 +149,6 @@ class DBInstance(resource.Resource):
class DBInstanceTest(common.HeatTestCase):
def setUp(self):
super(DBInstanceTest, self).setUp()
def test_dbinstance(self):
"""Test that Template is parsable and publishes correct properties."""
templ = template.Template(template_format.parse(rds_template))

3
heat/tests/test_engine_service.py

@ -113,9 +113,6 @@ resources:
class StackCreateTest(common.HeatTestCase):
def setUp(self):
super(StackCreateTest, self).setUp()
def test_wordpress_single_instance_stack_create(self):
stack = tools.get_stack('test_stack', utils.dummy_context())
tools.setup_mocks(self.m, stack)

3
heat/tests/test_event.py

@ -77,9 +77,6 @@ tmpl_multiple_srsly_too_large = {
class EventCommon(common.HeatTestCase):
def setUp(self):
super(EventCommon, self).setUp()
def _setup_stack(self, the_tmpl):
self.username = 'event_test_user'

3
heat/tests/test_lifecycle_plugin_utils.py

@ -33,9 +33,6 @@ class LifecyclePluginUtilsTest(common.HeatTestCase):
:module:'heat.common.lifecycle_plugin_utils'.
"""
def setUp(self):
super(LifecyclePluginUtilsTest, self).setUp()
def tearDown(self):
super(LifecyclePluginUtilsTest, self).tearDown()
lifecycle_plugin_utils.pp_class_instances = None

3
heat/tests/test_timeutils.py

@ -20,9 +20,6 @@ from heat.tests import common
class ISO8601UtilityTest(common.HeatTestCase):
def setUp(self):
super(ISO8601UtilityTest, self).setUp()
def test_valid_durations(self):
self.assertEqual(0, util.parse_isoduration('PT'))
self.assertEqual(3600, util.parse_isoduration('PT1H'))

3
heat_integrationtests/functional/test_conditions.py

@ -307,9 +307,6 @@ resources:
class CreateUpdateResConditionTest(functional_base.FunctionalTestsBase):
def setUp(self):
super(CreateUpdateResConditionTest, self).setUp()
def res_assert_for_prod(self, resources, bj_prod=True, fj_zone=False,
shannxi_provice=False):
res_names = [res.resource_name for res in resources]

6
heat_integrationtests/functional/test_create_update.py

@ -74,9 +74,6 @@ def _change_rsrc_properties(template, rsrcs, values):
class CreateStackTest(functional_base.FunctionalTestsBase):
def setUp(self):
super(CreateStackTest, self).setUp()
def test_create_rollback(self):
values = {'fail': True, 'value': 'test_create_rollback'}
template = _change_rsrc_properties(test_template_one_resource,
@ -153,9 +150,6 @@ resources:
wait_secs: 1
'''
def setUp(self):
super(UpdateStackTest, self).setUp()
def test_stack_update_nochange(self):
template = _change_rsrc_properties(test_template_one_resource,
['test1'],

3
heat_integrationtests/functional/test_create_update_neutron_subnet.py

@ -36,9 +36,6 @@ outputs:
class UpdateSubnetTest(functional_base.FunctionalTestsBase):
def setUp(self):
super(UpdateSubnetTest, self).setUp()
def get_outputs(self, stack_identifier, output_key):
stack = self.client.stacks.get(stack_identifier)
output = self._stack_output(stack, output_key)

3
heat_integrationtests/functional/test_default_parameters.py

@ -63,9 +63,6 @@ outputs:
expect1=12, expect2=12)),
]
def setUp(self):
super(DefaultParametersTest, self).setUp()
def test_defaults(self):
env = {'parameters': {}, 'parameter_defaults': {}}
if self.param:

3
heat_integrationtests/functional/test_encrypted_parameter.py

@ -43,9 +43,6 @@ outputs:
value: { get_param: foo }
'''
def setUp(self):
super(EncryptedParametersTest, self).setUp()
def test_db_encryption(self):
# Create a stack with the value of 'foo' to be encrypted
foo_param = 'my_encrypted_foo'

6
heat_integrationtests/functional/test_heat_autoscaling.py

@ -72,9 +72,6 @@ outputs:
value: {get_attr: [random_str, value]}
'''
def setUp(self):
super(HeatAutoscalingTest, self).setUp()
def _assert_output_values(self, stack_id):
stack = self.client.stacks.get(stack_id)
all_values = self._stack_output(stack, 'all_values')
@ -120,9 +117,6 @@ resources:
scaling_adjustment: 1
'''
def setUp(self):
super(AutoScalingGroupUpdateWithNoChanges, self).setUp()
def test_as_group_update_without_resource_changes(self):
stack_identifier = self.stack_create(template=self.template)
new_template = self.template.replace(

12
heat_integrationtests/functional/test_resource_group.py

@ -42,9 +42,6 @@ outputs:
value: {get_attr: [random_group, value]}
'''
def setUp(self):
super(ResourceGroupTest, self).setUp()
def test_resource_group_zero_novalidate(self):
# Nested resources should be validated only when size > 0
# This allows features to be disabled via size=0 without
@ -377,9 +374,6 @@ outputs:
)),
]
def setUp(self):
super(ResourceGroupTestNullParams, self).setUp()
def test_create_pass_zero_parameter(self):
templ = self.template.replace('type: empty',
'type: %s' % self.p_type)
@ -417,9 +411,6 @@ outputs:
value: {get_attr: [group1, resource.1.value]}
'''
def setUp(self):
super(ResourceGroupAdoptTest, self).setUp()
def _yaml_to_json(self, yaml_templ):
return yaml.safe_load(yaml_templ)
@ -489,9 +480,6 @@ resources:
wait_secs: 2
'''
def setUp(self):
super(ResourceGroupErrorResourceTest, self).setUp()
def test_fail(self):
stack_identifier = self.stack_create(
template=self.template,

3
heat_integrationtests/functional/test_stack_events.py

@ -32,9 +32,6 @@ outputs:
value: { get_resource: test_resource }
'''
def setUp(self):
super(StackEventsTest, self).setUp()
def _verify_event_fields(self, event, event_characteristics):
self.assertIsNotNone(event_characteristics)
self.assertIsNotNone(event.event_time)

3
heat_integrationtests/functional/test_swiftsignal_update.py

@ -33,9 +33,6 @@ outputs:
class SwiftSignalHandleUpdateTest(functional_base.FunctionalTestsBase):
def setUp(self):
super(SwiftSignalHandleUpdateTest, self).setUp()
def test_stack_update_same_template_replace_no_url(self):
stack_identifier = self.stack_create(template=test_template)
stack = self.client.stacks.get(stack_identifier)

21
heat_integrationtests/functional/test_template_resource.py

@ -47,9 +47,6 @@ resource_registry:
"OS::Heat::RandomString": nested.yaml
'''
def setUp(self):
super(TemplateResourceTest, self).setUp()
def test_nested_env(self):
main_templ = '''
heat_template_version: 2013-05-23
@ -172,9 +169,6 @@ resource_registry:
"My::NestedSecret": nested.yaml
'''
def setUp(self):
super(NestedAttributesTest, self).setUp()
def test_stack_ref(self):
nested_templ = '''
heat_template_version: 2014-10-16
@ -496,9 +490,6 @@ Outputs:
expect=NOCHANGE)),
]
def setUp(self):
super(TemplateResourceUpdateTest, self).setUp()
def test_template_resource_update_template_schema(self):
stack_identifier = self.stack_create(
template=self.main_template,
@ -598,9 +589,6 @@ Outputs:
Value: {'Fn::GetAtt': [RealRandom, value]}
'''
def setUp(self):
super(TemplateResourceAdoptTest, self).setUp()
def _yaml_to_json(self, yaml_templ):
return yaml.safe_load(yaml_templ)
@ -680,9 +668,6 @@ Outputs:
Value: {'Fn::GetAtt': [RealRandom, value]}
'''
def setUp(self):
super(TemplateResourceCheckTest, self).setUp()
def test_check(self):
stack_identifier = self.stack_create(
template=self.main_template,
@ -712,9 +697,6 @@ Resources:
wait_secs: 2
'''
def setUp(self):
super(TemplateResourceErrorMessageTest, self).setUp()
def test_fail(self):
stack_identifier = self.stack_create(
template=self.template,
@ -747,9 +729,6 @@ resources:
type: OS::Heat::RandomString
'''
def setUp(self):
super(TemplateResourceSuspendResumeTest, self).setUp()
def test_suspend_resume(self):
"""Basic test for template resource suspend resume."""
stack_identifier = self.stack_create(

3
heat_integrationtests/functional/test_templates.py

@ -39,9 +39,6 @@ class TemplateAPITest(functional_base.FunctionalTestsBase):
}
}
def setUp(self):
super(TemplateAPITest, self).setUp()
def test_get_stack_template(self):
stack_identifier = self.stack_create(
template=self.template

3
heat_integrationtests/functional/test_unicode_template.py

@ -35,9 +35,6 @@ outputs:
value: {get_attr: [\u8d44\u6e90, value]}
'''
def setUp(self):
super(StackUnicodeTemplateTest, self).setUp()
def _assert_results(self, result):
self.assertTrue(result['disable_rollback'])
self.assertIsNone(result['parent'])

Loading…
Cancel
Save