Replace assertRaisesRegexp with assertRaisesRegex
assertRaisesRegexp was renamed to assertRaisesRegex in Py3.2 For more details, please check: https://docs.python.org/3/library/ unittest.html#unittest.TestCase.assertRaisesRegex Change-Id: Ib5e52abde4cd642c3d214d3e29e8c55843983f2d
This commit is contained in:
parent
4dea571014
commit
e98cd6cd0c
|
@ -62,8 +62,8 @@ class TestFields(testtools.TestCase):
|
|||
|
||||
@mock.patch.object(fields, 'LOG')
|
||||
def test_fields_except_validation_error(self, mock_log):
|
||||
with self.assertRaisesRegexp(forms.ValidationError,
|
||||
"Can't get a request information"):
|
||||
with self.assertRaisesRegex(forms.ValidationError,
|
||||
"Can't get a request information"):
|
||||
self._test_fields_decorator_with_validation_error({}, request=None)
|
||||
mock_log.error.assert_called_once_with(
|
||||
"No 'request' value passed neither via initial dictionary, nor "
|
||||
|
@ -124,7 +124,7 @@ class TestFields(testtools.TestCase):
|
|||
def _validator(value):
|
||||
raise forms.ValidationError(None)
|
||||
|
||||
with self.assertRaisesRegexp(forms.ValidationError, 'foo'):
|
||||
with self.assertRaisesRegex(forms.ValidationError, 'foo'):
|
||||
func = fields.wrap_regex_validator(_validator, 'foo')
|
||||
func(None)
|
||||
|
||||
|
|
|
@ -194,8 +194,8 @@ class TestServiceConfigurationForm(testtools.TestCase):
|
|||
test_validator = {'expr': mock_expr, 'message': 'Foo Error'}
|
||||
|
||||
self.form.validators = [test_validator]
|
||||
with self.assertRaisesRegexp(django_forms.ValidationError,
|
||||
'Foo Error'):
|
||||
with self.assertRaisesRegex(django_forms.ValidationError,
|
||||
'Foo Error'):
|
||||
self.form.clean()
|
||||
|
||||
self.form.service.update_cleaned_data.assert_called_once_with(
|
||||
|
|
|
@ -100,8 +100,8 @@ class TestService(helpers.APITestCase):
|
|||
self.assertEqual(val, getattr(service.forms[0].service, key))
|
||||
|
||||
def test_init_service_except_value_error(self):
|
||||
with self.assertRaisesRegexp(ValueError,
|
||||
'Application section is required'):
|
||||
with self.assertRaisesRegex(ValueError,
|
||||
'Application section is required'):
|
||||
services.Service(cleaned_data={},
|
||||
version=2,
|
||||
fqn='io.murano.Test',
|
||||
|
|
|
@ -403,7 +403,7 @@ class TestUpdateEnvironmentRow(testtools.TestCase):
|
|||
|
||||
data_table = tables.UpdateEnvironmentRow(self.mock_data_table)
|
||||
|
||||
with self.assertRaisesRegexp(django_http.Http404, None):
|
||||
with self.assertRaisesRegex(django_http.Http404, None):
|
||||
data_table.get_data(None, 'foo_environment_id')
|
||||
|
||||
@mock.patch.object(tables, 'api')
|
||||
|
@ -412,7 +412,7 @@ class TestUpdateEnvironmentRow(testtools.TestCase):
|
|||
|
||||
data_table = tables.UpdateEnvironmentRow(self.mock_data_table)
|
||||
|
||||
with self.assertRaisesRegexp(Exception, 'foo_error'):
|
||||
with self.assertRaisesRegex(Exception, 'foo_error'):
|
||||
data_table.get_data(None, 'foo_environment_id')
|
||||
|
||||
|
||||
|
|
|
@ -39,8 +39,8 @@ class TestImportBundleForm(helpers.APITestCase):
|
|||
'import_type': 'by_{0}'.format(attr), attr: None}
|
||||
expected_error_msg = 'Please supply a bundle {0}'.format(attr)
|
||||
|
||||
with self.assertRaisesRegexp(django_forms.ValidationError,
|
||||
expected_error_msg):
|
||||
with self.assertRaisesRegex(django_forms.ValidationError,
|
||||
expected_error_msg):
|
||||
import_bundle_form.clean()
|
||||
|
||||
|
||||
|
@ -74,8 +74,8 @@ class TestImportPackageForm(helpers.APITestCase):
|
|||
|
||||
expected_error_msg = 'It is forbidden to upload files larger than {0} '\
|
||||
'MB.'.format(consts.MAX_FILE_SIZE_MB)
|
||||
with self.assertRaisesRegexp(django_forms.ValidationError,
|
||||
expected_error_msg):
|
||||
with self.assertRaisesRegex(django_forms.ValidationError,
|
||||
expected_error_msg):
|
||||
self.import_pkg_form.clean_package()
|
||||
|
||||
def test_clean_form(self):
|
||||
|
@ -100,8 +100,8 @@ class TestImportPackageForm(helpers.APITestCase):
|
|||
expected_error_msg = 'Please supply a package {0}'.\
|
||||
format(_tuple[2])
|
||||
|
||||
with self.assertRaisesRegexp(django_forms.ValidationError,
|
||||
expected_error_msg):
|
||||
with self.assertRaisesRegex(django_forms.ValidationError,
|
||||
expected_error_msg):
|
||||
self.import_pkg_form.clean()
|
||||
|
||||
|
||||
|
|
|
@ -485,7 +485,7 @@ class TestImportPackageWizard(helpers.APITestCase):
|
|||
mock_json.loads.side_effect = ValueError('test_error_message')
|
||||
original_e = ValueError('original_error_message')
|
||||
setattr(original_e, 'details', 'error_details')
|
||||
with self.assertRaisesRegexp(ValueError, 'original_error_message'):
|
||||
with self.assertRaisesRegex(ValueError, 'original_error_message'):
|
||||
self.import_pkg_wizard._handle_exception(original_e)
|
||||
|
||||
@mock.patch.object(views, 'glance')
|
||||
|
@ -564,8 +564,8 @@ class TestImportPackageWizard(helpers.APITestCase):
|
|||
exception.message = error_message
|
||||
mock_murano_utils.Package.from_file.side_effect = exception
|
||||
|
||||
with self.assertRaisesRegexp(horizon_exceptions.Http302,
|
||||
None):
|
||||
with self.assertRaisesRegex(horizon_exceptions.Http302,
|
||||
None):
|
||||
self.import_pkg_wizard.process_step(mock_form)
|
||||
|
||||
mock_log.exception.assert_called_once_with(expected_error_message)
|
||||
|
@ -915,7 +915,7 @@ class TestImportBundleWizard(helpers.APITestCase):
|
|||
for exception, expected_error_message in errors:
|
||||
mock_murano_utils.Bundle.from_file.side_effect = exception
|
||||
|
||||
with self.assertRaisesRegexp(horizon_exceptions.Http302, None):
|
||||
with self.assertRaisesRegex(horizon_exceptions.Http302, None):
|
||||
self.import_bundle_wizard.process_step(mock_form)
|
||||
|
||||
mock_log.exception.assert_called_once_with(expected_error_message)
|
||||
|
|
Loading…
Reference in New Issue