Merge "Replace deprecated assertEquals with assertEqual"

This commit is contained in:
Jenkins 2015-05-14 14:24:51 +00:00 committed by Gerrit Code Review
commit f28ec1354e
7 changed files with 96 additions and 96 deletions

View File

@ -101,14 +101,14 @@ class WSMECorniceTestCase(unittest.TestCase):
def test_get_json_list(self):
resp = self.app.get('/users')
self.assertEquals(
self.assertEqual(
resp.body,
'[{"id": 1, "name": "first"}]'
)
def test_get_xml_list(self):
resp = self.app.get('/users', headers={"Accept": "text/xml"})
self.assertEquals(
self.assertEqual(
resp.body,
'<result><item><id>1</id><name>first</name></item></result>'
)
@ -119,7 +119,7 @@ class WSMECorniceTestCase(unittest.TestCase):
'/users', data,
headers={"Content-Type": "application/json"}
)
self.assertEquals(
self.assertEqual(
resp.body,
'{"id": 2, "name": "new"}'
)
@ -130,7 +130,7 @@ class WSMECorniceTestCase(unittest.TestCase):
'/users', data,
headers={"Content-Type": "text/xml"}
)
self.assertEquals(
self.assertEqual(
resp.body,
'<result><id>2</id><name>new</name></result>'
)
@ -161,8 +161,8 @@ class WSMECorniceTestCase(unittest.TestCase):
def test_server_error(self):
resp = self.app.get('/divide?a=1&b=0', expect_errors=True)
self.assertEquals(resp.json['faultcode'], 'Server')
self.assertEquals(resp.status_code, 500)
self.assertEqual(resp.json['faultcode'], 'Server')
self.assertEqual(resp.status_code, 500)
def test_client_error(self):
resp = self.app.get(
@ -171,8 +171,8 @@ class WSMECorniceTestCase(unittest.TestCase):
expect_errors=True
)
print resp.body
self.assertEquals(resp.json['faultcode'], 'Client')
self.assertEquals(resp.status_code, 400)
self.assertEqual(resp.json['faultcode'], 'Client')
self.assertEqual(resp.status_code, 400)
def test_runtime_error(self):
resp = self.app.get(
@ -181,5 +181,5 @@ class WSMECorniceTestCase(unittest.TestCase):
expect_errors=True
)
print resp.body
self.assertEquals(resp.json['faultcode'], 'Client')
self.assertEquals(resp.status_code, 401)
self.assertEqual(resp.json['faultcode'], 'Client')
self.assertEqual(resp.status_code, 401)

View File

@ -118,7 +118,7 @@ class FlaskrTestCase(unittest.TestCase):
def test_array_parameter(self):
resp = self.app.get('/models?q.op=%3D&q.attr=name&q.value=second')
assert resp.status_code == 200
self.assertEquals(
self.assertEqual(
resp.data, b'[{"name": "second"}]'
)
@ -178,8 +178,8 @@ class FlaskrTestCase(unittest.TestCase):
r = self.app.get('/divide_by_zero')
assert r.status_code == 500
data = json.loads(r.data)
self.assertEquals(data['debuginfo'], None)
self.assertEquals(data['faultcode'], 'Server')
self.assertEqual(data['debuginfo'], None)
self.assertEqual(data['faultcode'], 'Server')
self.assertIn('by zero', data['faultstring'])
def test_restful_get(self):

View File

@ -167,7 +167,7 @@ class TestController(unittest.TestCase):
api = list(wsmeext.tg1._scan_api(root))
print(api)
self.assertEquals(len(api), 0)
self.assertEqual(len(api), 0)
def test_scan_api_maxlen(self):
class ARoot(object):
@ -186,11 +186,11 @@ class TestController(unittest.TestCase):
self.assertRaises(ValueError, list, wsmeext.tg1._scan_api(root))
def test_templates_content_type(self):
self.assertEquals(
self.assertEqual(
"application/json",
wsmeext.tg1.AutoJSONTemplate().get_content_type('dummy')
)
self.assertEquals(
self.assertEqual(
"text/xml",
wsmeext.tg1.AutoXMLTemplate().get_content_type('dummy')
)

View File

@ -148,7 +148,7 @@ class TestController(testutil.TGTest):
api = list(wsmeext.tg1._scan_api(root))
print(api)
self.assertEquals(len(api), 0)
self.assertEqual(len(api), 0)
def test_scan_api_maxlen(self):
class ARoot(object):
@ -167,11 +167,11 @@ class TestController(testutil.TGTest):
self.assertRaises(ValueError, list, wsmeext.tg1._scan_api(root))
def test_templates_content_type(self):
self.assertEquals(
self.assertEqual(
"application/json",
wsmeext.tg1.AutoJSONTemplate().get_content_type('dummy')
)
self.assertEquals(
self.assertEqual(
"text/xml",
wsmeext.tg1.AutoXMLTemplate().get_content_type('dummy')
)

View File

@ -172,7 +172,7 @@ class ReturnTypes(object):
class ArgTypes(object):
def assertEquals(self, a, b):
def assertEqual(self, a, b):
if not (a == b):
raise AssertionError('%s != %s' % (a, b))
@ -184,141 +184,141 @@ class ArgTypes(object):
@validate(wsme.types.bytes)
def setbytes(self, value):
print(repr(value))
self.assertEquals(type(value), wsme.types.bytes)
self.assertEqual(type(value), wsme.types.bytes)
return value
@expose(wsme.types.text)
@validate(wsme.types.text)
def settext(self, value):
print(repr(value))
self.assertEquals(type(value), wsme.types.text)
self.assertEqual(type(value), wsme.types.text)
return value
@expose(wsme.types.text)
@validate(wsme.types.text)
def settextnone(self, value):
print(repr(value))
self.assertEquals(type(value), type(None))
self.assertEqual(type(value), type(None))
return value
@expose(bool)
@validate(bool)
def setbool(self, value):
print(repr(value))
self.assertEquals(type(value), bool)
self.assertEqual(type(value), bool)
return value
@expose(int)
@validate(int)
def setint(self, value):
print(repr(value))
self.assertEquals(type(value), int)
self.assertEqual(type(value), int)
return value
@expose(float)
@validate(float)
def setfloat(self, value):
print(repr(value))
self.assertEquals(type(value), float)
self.assertEqual(type(value), float)
return value
@expose(decimal.Decimal)
@validate(decimal.Decimal)
def setdecimal(self, value):
print(repr(value))
self.assertEquals(type(value), decimal.Decimal)
self.assertEqual(type(value), decimal.Decimal)
return value
@expose(datetime.date)
@validate(datetime.date)
def setdate(self, value):
print(repr(value))
self.assertEquals(type(value), datetime.date)
self.assertEqual(type(value), datetime.date)
return value
@expose(datetime.time)
@validate(datetime.time)
def settime(self, value):
print(repr(value))
self.assertEquals(type(value), datetime.time)
self.assertEqual(type(value), datetime.time)
return value
@expose(datetime.datetime)
@validate(datetime.datetime)
def setdatetime(self, value):
print(repr(value))
self.assertEquals(type(value), datetime.datetime)
self.assertEqual(type(value), datetime.datetime)
return value
@expose(wsme.types.binary)
@validate(wsme.types.binary)
def setbinary(self, value):
print(repr(value))
self.assertEquals(type(value), six.binary_type)
self.assertEqual(type(value), six.binary_type)
return value
@expose([wsme.types.bytes])
@validate([wsme.types.bytes])
def setbytesarray(self, value):
print(repr(value))
self.assertEquals(type(value), list)
self.assertEquals(type(value[0]), wsme.types.bytes)
self.assertEqual(type(value), list)
self.assertEqual(type(value[0]), wsme.types.bytes)
return value
@expose([wsme.types.text])
@validate([wsme.types.text])
def settextarray(self, value):
print(repr(value))
self.assertEquals(type(value), list)
self.assertEquals(type(value[0]), wsme.types.text)
self.assertEqual(type(value), list)
self.assertEqual(type(value[0]), wsme.types.text)
return value
@expose([datetime.datetime])
@validate([datetime.datetime])
def setdatetimearray(self, value):
print(repr(value))
self.assertEquals(type(value), list)
self.assertEquals(type(value[0]), datetime.datetime)
self.assertEqual(type(value), list)
self.assertEqual(type(value[0]), datetime.datetime)
return value
@expose(NestedOuter)
@validate(NestedOuter)
def setnested(self, value):
print(repr(value))
self.assertEquals(type(value), NestedOuter)
self.assertEqual(type(value), NestedOuter)
return value
@expose([NestedOuter])
@validate([NestedOuter])
def setnestedarray(self, value):
print(repr(value))
self.assertEquals(type(value), list)
self.assertEquals(type(value[0]), NestedOuter)
self.assertEqual(type(value), list)
self.assertEqual(type(value[0]), NestedOuter)
return value
@expose({wsme.types.bytes: NestedOuter})
@validate({wsme.types.bytes: NestedOuter})
def setnesteddict(self, value):
print(repr(value))
self.assertEquals(type(value), dict)
self.assertEquals(type(list(value.keys())[0]), wsme.types.bytes)
self.assertEquals(type(list(value.values())[0]), NestedOuter)
self.assertEqual(type(value), dict)
self.assertEqual(type(list(value.keys())[0]), wsme.types.bytes)
self.assertEqual(type(list(value.values())[0]), NestedOuter)
return value
@expose(myenumtype)
@validate(myenumtype)
def setenum(self, value):
print(value)
self.assertEquals(type(value), wsme.types.bytes)
self.assertEqual(type(value), wsme.types.bytes)
return value
@expose(NamedAttrsObject)
@validate(NamedAttrsObject)
def setnamedattrsobj(self, value):
print(value)
self.assertEquals(type(value), NamedAttrsObject)
self.assertEquals(value.attr_1, 10)
self.assertEquals(value.attr_2, 20)
self.assertEqual(type(value), NamedAttrsObject)
self.assertEqual(value.attr_1, 10)
self.assertEqual(value.attr_2, 20)
return value
@expose(CustomObject)
@ -332,12 +332,12 @@ class ArgTypes(object):
@expose(ExtendedInt())
@validate(ExtendedInt())
def setextendedint(self, value):
self.assertEquals(isinstance(value, ExtendedInt.basetype), True)
self.assertEqual(isinstance(value, ExtendedInt.basetype), True)
return value
class BodyTypes(object):
def assertEquals(self, a, b):
def assertEqual(self, a, b):
if not (a == b):
raise AssertionError('%s != %s' % (a, b))
@ -345,18 +345,18 @@ class BodyTypes(object):
@validate(int)
def setdict(self, body):
print(body)
self.assertEquals(type(body), dict)
self.assertEquals(type(body['test']), int)
self.assertEquals(body['test'], 10)
self.assertEqual(type(body), dict)
self.assertEqual(type(body['test']), int)
self.assertEqual(body['test'], 10)
return body['test']
@expose(int, body=[int])
@validate(int)
def setlist(self, body):
print(body)
self.assertEquals(type(body), list)
self.assertEquals(type(body[0]), int)
self.assertEquals(body[0], 10)
self.assertEqual(type(body), list)
self.assertEqual(type(body[0]), int)
self.assertEqual(body[0], 10)
return body[0]
@ -397,7 +397,7 @@ class ProtocolTestCase(unittest.TestCase):
a = convert(a)
if isinstance(b, six.string_types):
b = convert(b)
self.assertEquals(a, b)
self.assertEqual(a, b)
def assertDateEquals(self, a, b):
self.assertTypedEquals(a, b, wsme.utils.parse_isodate)
@ -431,9 +431,9 @@ class ProtocolTestCase(unittest.TestCase):
print(res)
assert "No error raised"
except CallException as e:
self.assertEquals(e.faultcode, 'Client')
self.assertEquals(e.faultstring.lower(),
u('unknown function name: invalid_function'))
self.assertEqual(e.faultcode, 'Client')
self.assertEqual(e.faultstring.lower(),
u('unknown function name: invalid_function'))
def test_serverside_error(self):
try:
@ -441,8 +441,8 @@ class ProtocolTestCase(unittest.TestCase):
print(res)
assert "No error raised"
except CallException as e:
self.assertEquals(e.faultcode, 'Server')
self.assertEquals(e.faultstring, zerodivisionerrormsg)
self.assertEqual(e.faultcode, 'Server')
self.assertEqual(e.faultstring, zerodivisionerrormsg)
assert e.debuginfo is not None
def test_serverside_error_nodebug(self):
@ -452,8 +452,8 @@ class ProtocolTestCase(unittest.TestCase):
print(res)
assert "No error raised"
except CallException as e:
self.assertEquals(e.faultcode, 'Server')
self.assertEquals(e.faultstring, zerodivisionerrormsg)
self.assertEqual(e.faultcode, 'Server')
self.assertEqual(e.faultstring, zerodivisionerrormsg)
assert e.debuginfo is None
def test_touch(self):
@ -462,11 +462,11 @@ class ProtocolTestCase(unittest.TestCase):
def test_return_bytes(self):
r = self.call('returntypes/getbytes', _rt=wsme.types.bytes)
self.assertEquals(r, b('astring'))
self.assertEqual(r, b('astring'))
def test_return_text(self):
r = self.call('returntypes/gettext', _rt=wsme.types.text)
self.assertEquals(r, u('\xe3\x81\xae'))
self.assertEqual(r, u('\xe3\x81\xae'))
def test_return_int(self):
r = self.call('returntypes/getint')
@ -502,38 +502,38 @@ class ProtocolTestCase(unittest.TestCase):
def test_return_binary(self):
r = self.call('returntypes/getbinary', _rt=wsme.types.binary)
self.assertEquals(r, binarysample)
self.assertEqual(r, binarysample)
def test_return_nested(self):
r = self.call('returntypes/getnested', _rt=NestedOuter)
self.assertEquals(r, {'inner': {'aint': 0}})
self.assertEqual(r, {'inner': {'aint': 0}})
def test_return_bytesarray(self):
r = self.call('returntypes/getbytesarray', _rt=[six.binary_type])
self.assertEquals(r, [b('A'), b('B'), b('C')])
self.assertEqual(r, [b('A'), b('B'), b('C')])
def test_return_nestedarray(self):
r = self.call('returntypes/getnestedarray', _rt=[NestedOuter])
self.assertEquals(r, [{'inner': {'aint': 0}}, {'inner': {'aint': 0}}])
self.assertEqual(r, [{'inner': {'aint': 0}}, {'inner': {'aint': 0}}])
def test_return_nesteddict(self):
r = self.call('returntypes/getnesteddict',
_rt={wsme.types.bytes: NestedOuter})
self.assertEquals(r, {
self.assertEqual(r, {
b('a'): {'inner': {'aint': 0}},
b('b'): {'inner': {'aint': 0}}
})
def test_return_objectarrayattribute(self):
r = self.call('returntypes/getobjectarrayattribute', _rt=NestedOuter)
self.assertEquals(r, {
self.assertEqual(r, {
'inner': {'aint': 0},
'inner_array': [{'aint': 12}, {'aint': 13}]
})
def test_return_objectdictattribute(self):
r = self.call('returntypes/getobjectdictattribute', _rt=NestedOuter)
self.assertEquals(r, {
self.assertEqual(r, {
'inner': {'aint': 0},
'inner_dict': {
'12': {'aint': 12},
@ -543,11 +543,11 @@ class ProtocolTestCase(unittest.TestCase):
def test_return_enum(self):
r = self.call('returntypes/getenum', _rt=myenumtype)
self.assertEquals(r, b('v2'), r)
self.assertEqual(r, b('v2'), r)
def test_return_namedattrsobj(self):
r = self.call('returntypes/getnamedattrsobj', _rt=NamedAttrsObject)
self.assertEquals(r, {'attr.1': 5, 'attr.2': 6})
self.assertEqual(r, {'attr.1': 5, 'attr.2': 6})
def test_setbytes(self):
assert self.call('argtypes/setbytes', value=b('astring'),
@ -562,14 +562,14 @@ class ProtocolTestCase(unittest.TestCase):
_rt=wsme.types.text) == u('')
def test_settext_none(self):
self.assertEquals(
self.assertEqual(
None,
self.call('argtypes/settextnone', value=None, _rt=wsme.types.text)
)
def test_setint(self):
r = self.call('argtypes/setint', value=3, _rt=int)
self.assertEquals(r, 3)
self.assertEqual(r, 3)
def test_setfloat(self):
assert self.call('argtypes/setfloat', value=3.54,
@ -592,19 +592,19 @@ class ProtocolTestCase(unittest.TestCase):
value = datetime.date(2008, 4, 6)
r = self.call('argtypes/setdate', value=value,
_rt=datetime.date)
self.assertEquals(r, value)
self.assertEqual(r, value)
def test_settime(self):
value = datetime.time(12, 12, 15)
r = self.call('argtypes/settime', value=value,
_rt=datetime.time)
self.assertEquals(r, datetime.time(12, 12, 15))
self.assertEqual(r, datetime.time(12, 12, 15))
def test_setdatetime(self):
value = datetime.datetime(2008, 4, 6, 12, 12, 15)
r = self.call('argtypes/setdatetime', value=value,
_rt=datetime.datetime)
self.assertEquals(r, datetime.datetime(2008, 4, 6, 12, 12, 15))
self.assertEqual(r, datetime.datetime(2008, 4, 6, 12, 12, 15))
def test_setbinary(self):
value = binarysample
@ -617,7 +617,7 @@ class ProtocolTestCase(unittest.TestCase):
r = self.call('argtypes/setnested',
value=(value, NestedOuter),
_rt=NestedOuter)
self.assertEquals(r, value)
self.assertEqual(r, value)
def test_setnested_nullobj(self):
value = {'inner': None}
@ -626,21 +626,21 @@ class ProtocolTestCase(unittest.TestCase):
value=(value, NestedOuter),
_rt=NestedOuter
)
self.assertEquals(r, value)
self.assertEqual(r, value)
def test_setbytesarray(self):
value = [b("1"), b("2"), b("three")]
r = self.call('argtypes/setbytesarray',
value=(value, [wsme.types.bytes]),
_rt=[wsme.types.bytes])
self.assertEquals(r, value)
self.assertEqual(r, value)
def test_settextarray(self):
value = [u("1")]
r = self.call('argtypes/settextarray',
value=(value, [wsme.types.text]),
_rt=[wsme.types.text])
self.assertEquals(r, value)
self.assertEqual(r, value)
def test_setdatetimearray(self):
value = [
@ -650,7 +650,7 @@ class ProtocolTestCase(unittest.TestCase):
r = self.call('argtypes/setdatetimearray',
value=(value, [datetime.datetime]),
_rt=[datetime.datetime])
self.assertEquals(r, value)
self.assertEqual(r, value)
def test_setnestedarray(self):
value = [
@ -660,7 +660,7 @@ class ProtocolTestCase(unittest.TestCase):
r = self.call('argtypes/setnestedarray',
value=(value, [NestedOuter]),
_rt=[NestedOuter])
self.assertEquals(r, value)
self.assertEqual(r, value)
def test_setnesteddict(self):
value = {
@ -671,20 +671,20 @@ class ProtocolTestCase(unittest.TestCase):
value=(value, {six.binary_type: NestedOuter}),
_rt={six.binary_type: NestedOuter})
print(r)
self.assertEquals(r, value)
self.assertEqual(r, value)
def test_setenum(self):
value = b('v1')
r = self.call('argtypes/setenum', value=value,
_rt=myenumtype)
self.assertEquals(r, value)
self.assertEqual(r, value)
def test_setnamedattrsobj(self):
value = {'attr.1': 10, 'attr.2': 20}
r = self.call('argtypes/setnamedattrsobj',
value=(value, NamedAttrsObject),
_rt=NamedAttrsObject)
self.assertEquals(r, value)
self.assertEqual(r, value)
def test_nested_api(self):
r = self.call('nested/inner/deepfunction', _rt=bool)
@ -696,16 +696,16 @@ class ProtocolTestCase(unittest.TestCase):
print(r)
assert "No error raised"
except CallException as e:
self.assertEquals(e.faultcode, 'Client')
self.assertEquals(e.faultstring, u('Missing argument: "value"'))
self.assertEqual(e.faultcode, 'Client')
self.assertEqual(e.faultstring, u('Missing argument: "value"'))
def test_misc_multiply(self):
self.assertEquals(self.call('misc/multiply', a=5, b=2, _rt=int), 10)
self.assertEqual(self.call('misc/multiply', a=5, b=2, _rt=int), 10)
def test_html_format(self):
res = self.call('argtypes/setdatetime', _accept="text/html",
_no_result_decode=True)
self.assertEquals(res.content_type, 'text/html')
self.assertEqual(res.content_type, 'text/html')
class RestOnlyProtocolTestCase(ProtocolTestCase):

View File

@ -259,19 +259,19 @@ Value should be one of:"))
'Accept': 'application/json'
})
self.assertEquals(res.body, b('10'))
self.assertEqual(res.body, b('10'))
res = app.get('/mul_float?a=1.2&b=2.9', headers={
'Accept': 'application/json'
})
self.assertEquals(res.body, b('3.48'))
self.assertEqual(res.body, b('3.48'))
res = app.get('/mul_string?a=hello&b=2', headers={
'Accept': 'application/json'
})
self.assertEquals(res.body, b('"hellohello"'))
self.assertEqual(res.body, b('"hellohello"'))
def test_wsattr_mandatory(self):
class ComplexType(object):

View File

@ -397,7 +397,7 @@ class TestSOAP(wsme.tests.protocol.ProtocolTestCase):
assert len(sd.ports) == 1
port, methods = sd.ports[0]
self.assertEquals(len(methods), 51)
self.assertEqual(len(methods), 51)
methods = dict(methods)