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: I183178728c9a6c09a00d2a425d194308b2036997
Closes-Bug: #1436957
This commit is contained in:
Vu Cong Tuan 2017-06-03 12:42:02 +07:00
parent 7d85189395
commit 593e15bbf3
2 changed files with 16 additions and 16 deletions

View File

@ -68,9 +68,9 @@ class Test_check_resource(testtools.TestCase):
def test_strict_id(self):
decorated = proxy._check_resource(strict=True)(self.sot.method)
self.assertRaisesRegexp(ValueError, "A Resource must be passed",
decorated, self.sot, resource.Resource,
"this-is-not-a-resource")
self.assertRaisesRegex(ValueError, "A Resource must be passed",
decorated, self.sot, resource.Resource,
"this-is-not-a-resource")
def test_incorrect_resource(self):
class OneType(resource.Resource):
@ -81,9 +81,9 @@ class Test_check_resource(testtools.TestCase):
value = AnotherType()
decorated = proxy._check_resource(strict=False)(self.sot.method)
self.assertRaisesRegexp(ValueError,
"Expected OneType but received AnotherType",
decorated, self.sot, OneType, value)
self.assertRaisesRegex(ValueError,
"Expected OneType but received AnotherType",
decorated, self.sot, OneType, value)
class TestProxyDelete(testtools.TestCase):
@ -127,7 +127,7 @@ class TestProxyDelete(testtools.TestCase):
self.res.delete.side_effect = exceptions.NotFoundException(
message="test", http_status=404)
self.assertRaisesRegexp(
self.assertRaisesRegex(
exceptions.ResourceNotFound,
"No %s found for %s" % (DeleteableResource.__name__, self.res),
self.sot._delete, DeleteableResource, self.res,
@ -239,7 +239,7 @@ class TestProxyGet(testtools.TestCase):
self.res.get.side_effect = exceptions.NotFoundException(
message="test", http_status=404)
self.assertRaisesRegexp(
self.assertRaisesRegex(
exceptions.ResourceNotFound,
"No %s found for %s" % (RetrieveableResource.__name__, self.res),
self.sot._get, RetrieveableResource, self.res)

View File

@ -70,9 +70,9 @@ class TestProxyPrivate(testtools.TestCase):
def test__check_resource_strict_id(self):
decorated = proxy2._check_resource(strict=True)(self.sot.method)
self.assertRaisesRegexp(ValueError, "A Resource must be passed",
decorated, self.sot, resource2.Resource,
"this-is-not-a-resource")
self.assertRaisesRegex(ValueError, "A Resource must be passed",
decorated, self.sot, resource2.Resource,
"this-is-not-a-resource")
def test__check_resource_incorrect_resource(self):
class OneType(resource2.Resource):
@ -83,9 +83,9 @@ class TestProxyPrivate(testtools.TestCase):
value = AnotherType()
decorated = proxy2._check_resource(strict=False)(self.sot.method)
self.assertRaisesRegexp(ValueError,
"Expected OneType but received AnotherType",
decorated, self.sot, OneType, value)
self.assertRaisesRegex(ValueError,
"Expected OneType but received AnotherType",
decorated, self.sot, OneType, value)
def test__get_uri_attribute_no_parent(self):
class Child(resource2.Resource):
@ -199,7 +199,7 @@ class TestProxyDelete(testtools.TestCase):
self.res.delete.side_effect = exceptions.NotFoundException(
message="test", http_status=404)
self.assertRaisesRegexp(
self.assertRaisesRegex(
exceptions.ResourceNotFound,
"No %s found for %s" % (DeleteableResource.__name__, self.res),
self.sot._delete, DeleteableResource, self.res,
@ -312,7 +312,7 @@ class TestProxyGet(testtools.TestCase):
self.res.get.side_effect = exceptions.NotFoundException(
message="test", http_status=404)
self.assertRaisesRegexp(
self.assertRaisesRegex(
exceptions.ResourceNotFound,
"No %s found for %s" % (RetrieveableResource.__name__, self.res),
self.sot._get, RetrieveableResource, self.res)