Skip to content

Commit

Permalink
Swap out all assertEquals to the futureproof assertEqual
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.pyamf.org/branches/test-discovery-780@3363 2dde4cc4-cf3c-0410-b1a3-a9b8ff274da5
  • Loading branch information
njoyce committed Jun 5, 2010
1 parent 6657f87 commit cc3f59a
Show file tree
Hide file tree
Showing 29 changed files with 1,393 additions and 1,429 deletions.
5 changes: 1 addition & 4 deletions pyamf/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@

import os.path

try:
import unittest2 as unittest
except ImportError:
import unittest
import unittest


def get_suite():
Expand Down
4 changes: 2 additions & 2 deletions pyamf/tests/adapters/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ def encdec(self, encoding):
encoding=encoding).next()

def test_amf0(self):
self.assertEquals(self.encdec(pyamf.AMF0), self.orig)
self.assertEqual(self.encdec(pyamf.AMF0), self.orig)

def test_amf3(self):
self.assertEquals(self.encdec(pyamf.AMF3), self.orig)
self.assertEqual(self.encdec(pyamf.AMF3), self.orig)


def suite():
Expand Down
8 changes: 4 additions & 4 deletions pyamf/tests/adapters/test_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ def setUp(self):
self.obj = collections.deque(self.orig)

def test_amf0(self):
self.assertEquals(self.encdec(pyamf.AMF0), self.orig)
self.assertEqual(self.encdec(pyamf.AMF0), self.orig)

def test_amf3(self):
self.assertEquals(self.encdec(pyamf.AMF3), self.orig)
self.assertEqual(self.encdec(pyamf.AMF3), self.orig)


class DefaultDictTestCase(CollectionsTestCase):
Expand All @@ -54,10 +54,10 @@ def setUp(self):
self.orig = dict(self.obj)

def test_amf0(self):
self.assertEquals(self.encdec(pyamf.AMF3), self.orig)
self.assertEqual(self.encdec(pyamf.AMF3), self.orig)

def test_amf3(self):
self.assertEquals(self.encdec(pyamf.AMF3), self.orig)
self.assertEqual(self.encdec(pyamf.AMF3), self.orig)


def suite():
Expand Down
98 changes: 49 additions & 49 deletions pyamf/tests/adapters/test_django.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,23 +90,23 @@ class Spam(models.Model):
encoder = pyamf.get_encoder(pyamf.AMF0)

encoder.writeElement(Spam.objects.all())
self.assertEquals(encoder.stream.getvalue(), '\n\x00\x00\x00\x00')
self.assertEqual(encoder.stream.getvalue(), '\n\x00\x00\x00\x00')

encoder = pyamf.get_encoder(pyamf.AMF3)
encoder.writeElement(Spam.objects.all())
self.assertEquals(encoder.stream.getvalue(), '\t\x01\x01')
self.assertEqual(encoder.stream.getvalue(), '\t\x01\x01')

def test_NOT_PROVIDED(self):
from django.db.models import fields

encoder = pyamf.get_encoder(pyamf.AMF0)

encoder.writeElement(fields.NOT_PROVIDED)
self.assertEquals(encoder.stream.getvalue(), '\x06')
self.assertEqual(encoder.stream.getvalue(), '\x06')

encoder = pyamf.get_encoder(pyamf.AMF3)
encoder.writeElement(fields.NOT_PROVIDED)
self.assertEquals(encoder.stream.getvalue(), '\x00')
self.assertEqual(encoder.stream.getvalue(), '\x00')


class ClassAliasTestCase(ModelsBaseTestCase):
Expand All @@ -128,7 +128,7 @@ class TestClass(models.Model):

attrs = alias.getEncodableAttributes(x)

self.assertEquals(attrs, {
self.assertEqual(attrs, {
'id': None,
'd': datetime.datetime(2008, 3, 12, 0, 0),
'dt': datetime.datetime(2008, 3, 12, 12, 12, 12),
Expand All @@ -144,10 +144,10 @@ class TestClass(models.Model):
't': datetime.datetime(1970, 1, 1, 12, 12, 12)
})

self.assertEquals(y.id, None)
self.assertEquals(y.d, datetime.date(2008, 3, 12))
self.assertEquals(y.dt, datetime.datetime(2008, 3, 12, 12, 12, 12))
self.assertEquals(y.t, datetime.time(12, 12, 12))
self.assertEqual(y.id, None)
self.assertEqual(y.d, datetime.date(2008, 3, 12))
self.assertEqual(y.dt, datetime.datetime(2008, 3, 12, 12, 12, 12))
self.assertEqual(y.t, datetime.time(12, 12, 12))

y = TestClass()

Expand All @@ -158,10 +158,10 @@ class TestClass(models.Model):
't': None
})

self.assertEquals(y.id, None)
self.assertEquals(y.d, None)
self.assertEquals(y.dt, None)
self.assertEquals(y.t, None)
self.assertEqual(y.id, None)
self.assertEqual(y.d, None)
self.assertEqual(y.dt, None)
self.assertEqual(y.t, None)

def test_undefined(self):
from django.db import models
Expand All @@ -178,12 +178,12 @@ class UndefinedClass(models.Model):
'id': pyamf.Undefined
})

self.assertEquals(x.id, fields.NOT_PROVIDED)
self.assertEqual(x.id, fields.NOT_PROVIDED)

x.id = fields.NOT_PROVIDED

attrs = alias.getEncodableAttributes(x)
self.assertEquals(attrs, {'id': pyamf.Undefined})
self.assertEqual(attrs, {'id': pyamf.Undefined})

def test_non_field_prop(self):
from django.db import models
Expand All @@ -199,14 +199,14 @@ def _get_number_of_odd_pages(self):

x = Book()

self.assertEquals(alias.getEncodableAttributes(x),
self.assertEqual(alias.getEncodableAttributes(x),
{'numberOfOddPages': 234, 'id': None})

# now we test sending the numberOfOddPages attribute
alias.applyAttributes(x, {'numberOfOddPages': 24, 'id': None})

# test it hasn't been set
self.assertEquals(x.numberOfOddPages, 234)
self.assertEqual(x.numberOfOddPages, 234)

def test_dynamic(self):
"""
Expand All @@ -222,14 +222,14 @@ class Foo(models.Model):
x = Foo()
x.spam = 'eggs'

self.assertEquals(alias.getEncodableAttributes(x),
self.assertEqual(alias.getEncodableAttributes(x),
{'spam': 'eggs', 'id': None})

# now we test sending the numberOfOddPages attribute
alias.applyAttributes(x, {'spam': 'foo', 'id': None})

# test it has been set
self.assertEquals(x.spam, 'foo')
self.assertEqual(x.spam, 'foo')

def test_properties(self):
"""
Expand All @@ -252,7 +252,7 @@ def _set_days(self, val):

self.assertEqual(x.days, 1)

self.assertEquals(alias.getEncodableAttributes(x),
self.assertEqual(alias.getEncodableAttributes(x),
{'days': 1, 'id': None})

# now we test sending the numberOfOddPages attribute
Expand Down Expand Up @@ -291,7 +291,7 @@ def __unicode__(self):
a = Article(headline="This is a test", pub_date=datetime.date(2005, 7, 27), reporter=r)
a.save()

self.assertEquals(a.id, 1)
self.assertEqual(a.id, 1)

del a

Expand All @@ -310,14 +310,14 @@ def __unicode__(self):
attrs = alias.getEncodableAttributes(a)

# note that the reporter attribute does not exist.
self.assertEquals(attrs, {
self.assertEqual(attrs, {
'headline': u'This is a test',
'pub_date': datetime.datetime(2005, 7, 27, 0, 0),
'id': 1,
})

self.assertFalse('_reporter_cache' in a.__dict__)
self.assertEquals(pyamf.encode(a, encoding=pyamf.AMF3).getvalue(),
self.assertEqual(pyamf.encode(a, encoding=pyamf.AMF3).getvalue(),
'\n\x0b\x01\x11headline\x06\x1dThis is a test\x11pub_date\x08\x01'
'BpUYj@\x00\x00\x05id\x04\x01\x01')

Expand All @@ -329,15 +329,15 @@ def __unicode__(self):
alias = self.adapter.DjangoClassAlias(Article, defer=True)

self.assertFalse(hasattr(alias, 'fields'))
self.assertEquals(alias.getEncodableAttributes(a), {
self.assertEqual(alias.getEncodableAttributes(a), {
'headline': u'This is a test',
'pub_date': datetime.datetime(2005, 7, 27, 0, 0),
'id': 1,
'reporter': r,
})

self.assertTrue('_reporter_cache' in a.__dict__)
self.assertEquals(pyamf.encode(a, encoding=pyamf.AMF3).getvalue(),
self.assertEqual(pyamf.encode(a, encoding=pyamf.AMF3).getvalue(),
'\n\x0b\x01\x11reporter\n\x0b\x01\x15first_name\x06\tJohn\x13'
'last_name\x06\x0bSmith\x05id\x04\x01\x0bemail\x06!'
'[email protected]\x01\x11headline\x06\x1dThis is a test\x11'
Expand Down Expand Up @@ -379,7 +379,7 @@ class Meta:
# Create an Article.
a1 = Article2(id=None, headline='Django lets you build Web apps easily')
a1.save()
self.assertEquals(a1.id, 1)
self.assertEqual(a1.id, 1)

# Associate the Article with a Publication.
a1.publications.add(p1)
Expand All @@ -391,10 +391,10 @@ class Meta:
test_article = Article2.objects.filter(pk=1)[0]

attrs = pub_alias.getEncodableAttributes(test_publication)
self.assertEquals(attrs, {'id': 1, 'title': u'The Python Journal'})
self.assertEqual(attrs, {'id': 1, 'title': u'The Python Journal'})

attrs = art_alias.getEncodableAttributes(test_article)
self.assertEquals(attrs, {
self.assertEqual(attrs, {
'headline': u'Django lets you build Web apps easily',
'id': 1,
'publications': [p1]
Expand All @@ -407,13 +407,13 @@ class Meta:
'publications': [p1]
})

self.assertEquals(x.headline, u'Test')
self.assertEquals(x.id, 1)
self.assertEqual(x.headline, u'Test')
self.assertEqual(x.id, 1)

p = x.publications.all()

self.assertEquals(len(p), 1)
self.assertEquals(p[0], p1)
self.assertEqual(len(p), 1)
self.assertEqual(p[0], p1)

y = Article2()
attrs = art_alias.getDecodableAttributes(y, {
Expand Down Expand Up @@ -448,7 +448,7 @@ class BlankForeignKey(models.Model):

attrs = nfk_alias.getEncodableAttributes(nfk)

self.assertEquals(attrs, {'id': None})
self.assertEqual(attrs, {'id': None})

def test_static_relation(self):
"""
Expand Down Expand Up @@ -485,7 +485,7 @@ class I18NTestCase(ModelsBaseTestCase):
def test_encode(self):
from django.utils.translation import ugettext_lazy

self.assertEquals(pyamf.encode(ugettext_lazy('Hello')).getvalue(),
self.assertEqual(pyamf.encode(ugettext_lazy('Hello')).getvalue(),
'\x06\x0bHello')


Expand Down Expand Up @@ -528,7 +528,7 @@ class Meta:
p.save()
a.save()

self.assertEquals(a.id, 2)
self.assertEqual(a.id, 2)

article_alias = self.adapter.DjangoClassAlias(Article2, None)
x = Article2()
Expand All @@ -555,13 +555,13 @@ class Foo(models.Model):

x = Foo()

self.assertEquals(x.id, None)
self.assertEqual(x.id, None)

alias.applyAttributes(x, {
'id': 0
})

self.assertEquals(x.id, None)
self.assertEqual(x.id, None)

def test_no_pk(self):
"""
Expand All @@ -576,8 +576,8 @@ class NotSaved(models.Model):
instances = [NotSaved(name="a"), NotSaved(name="b")]
encoded = pyamf.encode(instances, encoding=pyamf.AMF3).getvalue()
decoded = pyamf.get_decoder(pyamf.AMF3, encoded).readElement()
self.assertEquals(decoded[0]['name'], 'a')
self.assertEquals(decoded[1]['name'], 'b')
self.assertEqual(decoded[0]['name'], 'a')
self.assertEqual(decoded[1]['name'], 'b')


class ModelInheritanceTestCase(ModelsBaseTestCase):
Expand Down Expand Up @@ -606,7 +606,7 @@ class Student(CommonInfo):

attrs = alias.getEncodableAttributes(x)

self.assertEquals(attrs, {
self.assertEqual(attrs, {
'age': None,
'home_group': '',
'id': None,
Expand All @@ -631,7 +631,7 @@ class Restaurant(Place):

attrs = alias.getEncodableAttributes(x)

self.assertEquals(attrs, {
self.assertEqual(attrs, {
'id': None,
'name': '',
'address': ''
Expand All @@ -642,7 +642,7 @@ class Restaurant(Place):

attrs = alias.getEncodableAttributes(x)

self.assertEquals(attrs, {
self.assertEqual(attrs, {
'id': None,
'name': '',
'address': '',
Expand Down Expand Up @@ -705,12 +705,12 @@ class Image(models.Model):

attrs = alias.getEncodableAttributes(i)

self.assertEquals(attrs, {'text': '', 'id': 1, 'file': u'foo'})
self.assertEqual(attrs, {'text': '', 'id': 1, 'file': u'foo'})
self.assertTrue(self.executed)

attrs = alias.getDecodableAttributes(i, attrs)

self.assertEquals(attrs, {'text': ''})
self.assertEqual(attrs, {'text': ''})


class ImageTestCase(ModelsBaseTestCase):
Expand Down Expand Up @@ -743,12 +743,12 @@ class Profile(models.Model):

attrs = alias.getEncodableAttributes(i)

self.assertEquals(attrs, {'text': '', 'id': 1, 'file': u'foo'})
self.assertEqual(attrs, {'text': '', 'id': 1, 'file': u'foo'})
self.assertTrue(self.executed)

attrs = alias.getDecodableAttributes(i, attrs)

self.assertEquals(attrs, {'text': ''})
self.assertEqual(attrs, {'text': ''})


class ReferenceTestCase(ModelsBaseTestCase):
Expand Down Expand Up @@ -795,7 +795,7 @@ def test_not_referenced(self):
f.bar = b
f.save()

self.assertEquals(f.id, 1)
self.assertEqual(f.id, 1)
foo = self.ParentReference.objects.select_related().get(id=1)

self.assertFalse(foo.bar.foo is foo)
Expand All @@ -813,13 +813,13 @@ def test_referenced_encode(self):
f.bar = b
f.save()

self.assertEquals(f.id, 2)
self.assertEqual(f.id, 2)
foo = self.ParentReference.objects.select_related().get(id=2)

# ensure the referenced attribute resolves
foo.bar.foo

self.assertEquals(pyamf.encode(foo).getvalue(), '\n\x0b\x01\x07bar\n'
self.assertEqual(pyamf.encode(foo).getvalue(), '\n\x0b\x01\x07bar\n'
'\x0b\x01\x07foo\n\x00\x05id\x04\x02\tname\x06\x00\x01\x04\x04'
'\x02\x06\x06\x02\x01')

Expand Down
Loading

0 comments on commit cc3f59a

Please sign in to comment.