Commit d557242d authored by Stephen Finucane's avatar Stephen Finucane Committed by Damien Lespiau

py3: Remove all deprecated UnitTest calls

Remove the likes of 'failUnlessEqual' and 'assertEquals', which have
been deprecated and cause warnings in Django 1.6 with Python 3.4.

https://docs.python.org/2/library/unittest.html#deprecated-aliases

This allows us to remove an item from the TODO list.

v2: Port to fdo's patchwork (Damien)
Signed-off-by: default avatarStephen Finucane <stephen.finucane@intel.com>
Signed-off-by: default avatarDamien Lespiau <damien.lespiau@intel.com>
parent 521d387f
......@@ -14,5 +14,3 @@
* pwclient: add example scripts (eg, git post-commit hook) to online help
* pwclient: case-insensitive searches for author and project name
* changing primary email addresses for accounts
* sed -i -e "s/\(assertEqual\)s/\1/g" $(git grep -l assertEquals)
and all in: https://docs.python.org/2/library/unittest.html#deprecated-aliases
......@@ -42,8 +42,8 @@ class BundleListTest(TestCase):
def testNoBundles(self):
response = self.client.get('/user/bundles/')
self.failUnlessEqual(response.status_code, 200)
self.failUnlessEqual(
self.assertEqual(response.status_code, 200)
self.assertEqual(
len(find_in_context(response.context, 'bundles')), 0)
def testSingleBundle(self):
......@@ -51,8 +51,8 @@ class BundleListTest(TestCase):
bundle = Bundle(owner = self.user, project = defaults.project)
bundle.save()
response = self.client.get('/user/bundles/')
self.failUnlessEqual(response.status_code, 200)
self.failUnlessEqual(
self.assertEqual(response.status_code, 200)
self.assertEqual(
len(find_in_context(response.context, 'bundles')), 1)
def tearDown(self):
......@@ -89,17 +89,17 @@ class BundleViewTest(BundleTestBase):
def testEmptyBundle(self):
response = self.client.get(bundle_url(self.bundle))
self.failUnlessEqual(response.status_code, 200)
self.assertEqual(response.status_code, 200)
page = find_in_context(response.context, 'page')
self.failUnlessEqual(len(page.object_list), 0)
self.assertEqual(len(page.object_list), 0)
def testNonEmptyBundle(self):
self.bundle.append_patch(self.patches[0])
response = self.client.get(bundle_url(self.bundle))
self.failUnlessEqual(response.status_code, 200)
self.assertEqual(response.status_code, 200)
page = find_in_context(response.context, 'page')
self.failUnlessEqual(len(page.object_list), 1)
self.assertEqual(len(page.object_list), 1)
def testBundleOrder(self):
for patch in self.patches:
......@@ -111,7 +111,7 @@ class BundleViewTest(BundleTestBase):
for patch in self.patches:
next_pos = response.content.decode().find(patch.name)
# ensure that this patch is after the previous
self.failUnless(next_pos > pos)
self.assertTrue(next_pos > pos)
pos = next_pos
# reorder and recheck
......@@ -128,7 +128,7 @@ class BundleViewTest(BundleTestBase):
for patch in self.patches:
next_pos = response.content.decode().find(patch.name)
# ensure that this patch is now *before* the previous
self.failUnless(next_pos < pos)
self.assertTrue(next_pos < pos)
pos = next_pos
class BundleUpdateTest(BundleTestBase):
......@@ -144,7 +144,7 @@ class BundleUpdateTest(BundleTestBase):
form = response.context[formname]
if not form:
return
self.assertEquals(form.errors, {})
self.assertEqual(form.errors, {})
def publicString(self, public):
if public:
......@@ -308,8 +308,8 @@ class BundleCreateFromListTest(BundleTestBase):
count = 1)
bundle = Bundle.objects.get(name = newbundlename)
self.failUnlessEqual(bundle.patches.count(), 1)
self.failUnlessEqual(bundle.patches.all()[0], patch)
self.assertEqual(bundle.patches.count(), 1)
self.assertEqual(bundle.patches.all()[0], patch)
def testCreateNonEmptyBundleEmptyName(self):
newbundlename = 'testbundle-new'
......@@ -331,7 +331,7 @@ class BundleCreateFromListTest(BundleTestBase):
status_code = 200)
# test that no new bundles are present
self.failUnlessEqual(n_bundles, Bundle.objects.count())
self.assertEqual(n_bundles, Bundle.objects.count())
def testCreateDuplicateName(self):
newbundlename = 'testbundle-dup'
......@@ -353,8 +353,8 @@ class BundleCreateFromListTest(BundleTestBase):
count = 1)
bundle = Bundle.objects.get(name = newbundlename)
self.failUnlessEqual(bundle.patches.count(), 1)
self.failUnlessEqual(bundle.patches.all()[0], patch)
self.assertEqual(bundle.patches.count(), 1)
self.assertEqual(bundle.patches.all()[0], patch)
response = self.client.post(
'/project/%s/list/' % defaults.project.linkname,
......@@ -379,8 +379,8 @@ class BundleCreateFromPatchTest(BundleTestBase):
'Bundle %s created' % newbundlename)
bundle = Bundle.objects.get(name = newbundlename)
self.failUnlessEqual(bundle.patches.count(), 1)
self.failUnlessEqual(bundle.patches.all()[0], patch)
self.assertEqual(bundle.patches.count(), 1)
self.assertEqual(bundle.patches.all()[0], patch)
def testCreateWithExistingName(self):
newbundlename = self.bundle.name
......@@ -395,7 +395,7 @@ class BundleCreateFromPatchTest(BundleTestBase):
'A bundle called %s already exists' % newbundlename)
count = Bundle.objects.count()
self.failUnlessEqual(Bundle.objects.count(), 1)
self.assertEqual(Bundle.objects.count(), 1)
class BundleAddFromListTest(BundleTestBase):
def testAddToEmptyBundle(self):
......@@ -413,8 +413,8 @@ class BundleAddFromListTest(BundleTestBase):
self.assertContains(response, 'added to bundle %s' % self.bundle.name,
count = 1)
self.failUnlessEqual(self.bundle.patches.count(), 1)
self.failUnlessEqual(self.bundle.patches.all()[0], patch)
self.assertEqual(self.bundle.patches.count(), 1)
self.assertEqual(self.bundle.patches.all()[0], patch)
def testAddToNonEmptyBundle(self):
self.bundle.append_patch(self.patches[0])
......@@ -432,15 +432,15 @@ class BundleAddFromListTest(BundleTestBase):
self.assertContains(response, 'added to bundle %s' % self.bundle.name,
count = 1)
self.failUnlessEqual(self.bundle.patches.count(), 2)
self.failUnless(self.patches[0] in self.bundle.patches.all())
self.failUnless(self.patches[1] in self.bundle.patches.all())
self.assertEqual(self.bundle.patches.count(), 2)
self.assertIn(self.patches[0], self.bundle.patches.all())
self.assertIn(self.patches[1], self.bundle.patches.all())
# check order
bps = [ BundlePatch.objects.get(bundle = self.bundle,
patch = self.patches[i]) \
for i in [0, 1] ]
self.failUnless(bps[0].order < bps[1].order)
self.assertTrue(bps[0].order < bps[1].order)
def testAddDuplicate(self):
self.bundle.append_patch(self.patches[0])
......@@ -460,7 +460,7 @@ class BundleAddFromListTest(BundleTestBase):
self.assertContains(response, 'Patch &#39;%s&#39; already in bundle' \
% patch.name, count = 1, status_code = 200)
self.assertEquals(count, self.bundle.patches.count())
self.assertEqual(count, self.bundle.patches.count())
def testAddNewAndDuplicate(self):
self.bundle.append_patch(self.patches[0])
......@@ -483,7 +483,7 @@ class BundleAddFromListTest(BundleTestBase):
self.assertContains(response, 'Patch &#39;%s&#39; added to bundle' \
% self.patches[1].name, count = 1,
status_code = 200)
self.assertEquals(count + 1, self.bundle.patches.count())
self.assertEqual(count + 1, self.bundle.patches.count())
class BundleAddFromPatchTest(BundleTestBase):
def testAddToEmptyBundle(self):
......@@ -497,8 +497,8 @@ class BundleAddFromPatchTest(BundleTestBase):
'added to bundle &quot;%s&quot;' % self.bundle.name,
count = 1)
self.failUnlessEqual(self.bundle.patches.count(), 1)
self.failUnlessEqual(self.bundle.patches.all()[0], patch)
self.assertEqual(self.bundle.patches.count(), 1)
self.assertEqual(self.bundle.patches.all()[0], patch)
def testAddToNonEmptyBundle(self):
self.bundle.append_patch(self.patches[0])
......@@ -512,15 +512,15 @@ class BundleAddFromPatchTest(BundleTestBase):
'added to bundle &quot;%s&quot;' % self.bundle.name,
count = 1)
self.failUnlessEqual(self.bundle.patches.count(), 2)
self.failUnless(self.patches[0] in self.bundle.patches.all())
self.failUnless(self.patches[1] in self.bundle.patches.all())
self.assertEqual(self.bundle.patches.count(), 2)
self.assertIn(self.patches[0], self.bundle.patches.all())
self.assertIn(self.patches[1], self.bundle.patches.all())
# check order
bps = [ BundlePatch.objects.get(bundle = self.bundle,
patch = self.patches[i]) \
for i in [0, 1] ]
self.failUnless(bps[0].order < bps[1].order)
self.assertTrue(bps[0].order < bps[1].order)
class BundleInitialOrderTest(BundleTestBase):
"""When creating bundles from a patch list, ensure that the patches in the
......@@ -601,19 +601,19 @@ class BundleReorderTest(BundleTestBase):
response = self.client.post(bundle_url(self.bundle), params)
self.failUnlessEqual(response.status_code, 200)
self.assertEqual(response.status_code, 200)
bps = BundlePatch.objects.filter(bundle = self.bundle) \
.order_by('order')
# check if patch IDs are in the expected order:
bundle_ids = [ bp.patch.id for bp in bps ]
self.failUnlessEqual(neworder_ids, bundle_ids)
self.assertEqual(neworder_ids, bundle_ids)
# check if order field is still sequential:
order_numbers = [ bp.order for bp in bps ]
expected_order = list(range(1, len(neworder)+1)) # [1 ... len(neworder)]
self.failUnlessEqual(order_numbers, expected_order)
self.assertEqual(order_numbers, expected_order)
def testBundleReorderAll(self):
# reorder all patches:
......
......@@ -52,7 +52,7 @@ class InvalidConfirmationTest(TestCase):
self.conf.active = False
self.conf.save()
response = self.client.get(_confirmation_url(self.conf))
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'patchwork/confirm-error.html')
self.assertEqual(response.context['error'], 'inactive')
self.assertEqual(response.context['conf'], self.conf)
......@@ -61,7 +61,7 @@ class InvalidConfirmationTest(TestCase):
self.conf.date -= self.conf.validity
self.conf.save()
response = self.client.get(_confirmation_url(self.conf))
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'patchwork/confirm-error.html')
self.assertEqual(response.context['error'], 'expired')
self.assertEqual(response.context['conf'], self.conf)
......
......@@ -51,14 +51,14 @@ class UTF8PatchViewTest(TestCase):
def testMboxView(self):
response = self.client.get('/patch/%d/mbox/' % self.patch.id)
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertTrue(self.patch.content in \
response.content.decode(self.patch_encoding))
def testRawView(self):
response = self.client.get('/patch/%d/raw/' % self.patch.id)
self.assertEquals(response.status_code, 200)
self.assertEquals(response.content.decode(self.patch_encoding),
self.assertEqual(response.status_code, 200)
self.assertEqual(response.content.decode(self.patch_encoding),
self.patch.content)
def tearDown(self):
......
......@@ -34,7 +34,7 @@ class FilterQueryStringTest(TestCase):
defaults.project.save()
url = '/project/%s/list/?submitter=a%%26b=c' % project.linkname
response = self.client.get(url)
self.failUnlessEqual(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertNotContains(response, 'submitter=a&amp;b=c')
self.assertNotContains(response, 'submitter=a&b=c')
......@@ -45,4 +45,4 @@ class FilterQueryStringTest(TestCase):
defaults.project.save()
url = '/project/%s/list/?submitter=%%E2%%98%%83' % project.linkname
response = self.client.get(url)
self.failUnlessEqual(response.status_code, 200)
self.assertEqual(response.status_code, 200)
......@@ -34,35 +34,35 @@ class MailSettingsTest(TestCase):
def testMailSettingsGET(self):
response = self.client.get(self.url)
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertTrue(response.context['form'])
def testMailSettingsPOST(self):
email = u'foo@example.com'
response = self.client.post(self.url, {'email': email})
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'patchwork/mail-settings.html')
self.assertEquals(response.context['email'], email)
self.assertEqual(response.context['email'], email)
def testMailSettingsPOSTEmpty(self):
response = self.client.post(self.url, {'email': ''})
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'patchwork/mail-form.html')
self.assertFormError(response, 'form', 'email',
'This field is required.')
def testMailSettingsPOSTInvalid(self):
response = self.client.post(self.url, {'email': 'foo'})
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'patchwork/mail-form.html')
self.assertFormError(response, 'form', 'email', error_strings['email'])
def testMailSettingsPOSTOptedIn(self):
email = u'foo@example.com'
response = self.client.post(self.url, {'email': email})
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'patchwork/mail-settings.html')
self.assertEquals(response.context['is_optout'], False)
self.assertEqual(response.context['is_optout'], False)
self.assertContains(response, '<strong>may</strong>')
optout_url = reverse('patchwork.views.mail.optout')
self.assertContains(response, ('action="%s"' % optout_url))
......@@ -71,9 +71,9 @@ class MailSettingsTest(TestCase):
email = u'foo@example.com'
EmailOptout(email = email).save()
response = self.client.post(self.url, {'email': email})
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'patchwork/mail-settings.html')
self.assertEquals(response.context['is_optout'], True)
self.assertEqual(response.context['is_optout'], True)
self.assertContains(response, '<strong>may not</strong>')
optin_url = reverse('patchwork.views.mail.optin')
self.assertContains(response, ('action="%s"' % optin_url))
......@@ -92,38 +92,38 @@ class OptoutRequestTest(TestCase):
response = self.client.post(self.url, {'email': email})
# check for a confirmation object
self.assertEquals(EmailConfirmation.objects.count(), 1)
self.assertEqual(EmailConfirmation.objects.count(), 1)
conf = EmailConfirmation.objects.get(email = email)
# check confirmation page
self.assertEquals(response.status_code, 200)
self.assertEquals(response.context['confirmation'], conf)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.context['confirmation'], conf)
self.assertContains(response, email)
# check email
url = reverse('patchwork.views.confirm', kwargs = {'key': conf.key})
self.assertEquals(len(mail.outbox), 1)
self.assertEqual(len(mail.outbox), 1)
msg = mail.outbox[0]
self.assertEquals(msg.to, [email])
self.assertEquals(msg.subject, 'Patchwork opt-out confirmation')
self.assertTrue(url in msg.body)
self.assertEqual(msg.to, [email])
self.assertEqual(msg.subject, 'Patchwork opt-out confirmation')
self.assertIn(url, msg.body)
def testOptoutRequestInvalidPOSTEmpty(self):
response = self.client.post(self.url, {'email': ''})
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertFormError(response, 'form', 'email',
'This field is required.')
self.assertTrue(response.context['error'])
self.assertTrue('email_sent' not in response.context)
self.assertEquals(len(mail.outbox), 0)
self.assertNotIn('email_sent', response.context)
self.assertEqual(len(mail.outbox), 0)
def testOptoutRequestInvalidPOSTNonEmail(self):
response = self.client.post(self.url, {'email': 'foo'})
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertFormError(response, 'form', 'email', error_strings['email'])
self.assertTrue(response.context['error'])
self.assertTrue('email_sent' not in response.context)
self.assertEquals(len(mail.outbox), 0)
self.assertNotIn('email_sent', response.context)
self.assertEqual(len(mail.outbox), 0)
class OptoutTest(TestCase):
......@@ -138,13 +138,13 @@ class OptoutTest(TestCase):
kwargs = {'key': self.conf.key})
response = self.client.get(url)
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'patchwork/optout.html')
self.assertContains(response, self.email)
# check that we've got an optout in the list
self.assertEquals(EmailOptout.objects.count(), 1)
self.assertEquals(EmailOptout.objects.all()[0].email, self.email)
self.assertEqual(EmailOptout.objects.count(), 1)
self.assertEqual(EmailOptout.objects.all()[0].email, self.email)
# check that the confirmation is now inactive
self.assertFalse(EmailConfirmation.objects.get(
......@@ -172,38 +172,38 @@ class OptinRequestTest(TestCase):
response = self.client.post(self.url, {'email': self.email})
# check for a confirmation object
self.assertEquals(EmailConfirmation.objects.count(), 1)
self.assertEqual(EmailConfirmation.objects.count(), 1)
conf = EmailConfirmation.objects.get(email = self.email)
# check confirmation page
self.assertEquals(response.status_code, 200)
self.assertEquals(response.context['confirmation'], conf)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.context['confirmation'], conf)
self.assertContains(response, self.email)
# check email
url = reverse('patchwork.views.confirm', kwargs = {'key': conf.key})
self.assertEquals(len(mail.outbox), 1)
self.assertEqual(len(mail.outbox), 1)
msg = mail.outbox[0]
self.assertEquals(msg.to, [self.email])
self.assertEquals(msg.subject, 'Patchwork opt-in confirmation')
self.assertTrue(url in msg.body)
self.assertEqual(msg.to, [self.email])
self.assertEqual(msg.subject, 'Patchwork opt-in confirmation')
self.assertIn(url, msg.body)
def testOptoutRequestInvalidPOSTEmpty(self):
response = self.client.post(self.url, {'email': ''})
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertFormError(response, 'form', 'email',
'This field is required.')
self.assertTrue(response.context['error'])
self.assertTrue('email_sent' not in response.context)
self.assertEquals(len(mail.outbox), 0)
self.assertNotIn('email_sent', response.context)
self.assertEqual(len(mail.outbox), 0)
def testOptoutRequestInvalidPOSTNonEmail(self):
response = self.client.post(self.url, {'email': 'foo'})
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertFormError(response, 'form', 'email', error_strings['email'])
self.assertTrue(response.context['error'])
self.assertTrue('email_sent' not in response.context)
self.assertEquals(len(mail.outbox), 0)
self.assertNotIn('email_sent', response.context)
self.assertEqual(len(mail.outbox), 0)
class OptinTest(TestCase):
......@@ -219,12 +219,12 @@ class OptinTest(TestCase):
kwargs = {'key': self.conf.key})
response = self.client.get(url)
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'patchwork/optin.html')
self.assertContains(response, self.email)
# check that there's no optout remaining
self.assertEquals(EmailOptout.objects.count(), 0)
self.assertEqual(EmailOptout.objects.count(), 0)
# check that the confirmation is now inactive
self.assertFalse(EmailConfirmation.objects.get(
......@@ -241,7 +241,7 @@ class OptinWithoutOptoutTest(TestCase):
response = self.client.post(self.url, {'email': email})
# check for an error message
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertTrue(bool(response.context['error']))
self.assertContains(response, 'not on the patchwork opt-out list')
......@@ -269,14 +269,14 @@ class UserProfileOptoutFormTest(TestCase):
def testMainEmailOptoutForm(self):
form_re = self._form_re(self.optout_url, self.user.email)
response = self.client.get(self.url)
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertTrue(form_re.search(response.content.decode()) is not None)
def testMainEmailOptinForm(self):
EmailOptout(email = self.user.email).save()
form_re = self._form_re(self.optin_url, self.user.email)
response = self.client.get(self.url)
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertTrue(form_re.search(response.content.decode()) is not None)
def testSecondaryEmailOptoutForm(self):
......@@ -284,7 +284,7 @@ class UserProfileOptoutFormTest(TestCase):
p.save()
form_re = self._form_re(self.optout_url, p.email)
response = self.client.get(self.url)
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertTrue(form_re.search(response.content.decode()) is not None)
def testSecondaryEmailOptinForm(self):
......@@ -294,5 +294,5 @@ class UserProfileOptoutFormTest(TestCase):
form_re = self._form_re(self.optin_url, p.email)
response = self.client.get(self.url)
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertTrue(form_re.search(response.content.decode()) is not None)
......@@ -153,7 +153,7 @@ class PatchNotificationEmailTest(TestCase):
qs.update(last_modified = timestamp)
def testNoNotifications(self):
self.assertEquals(send_notifications(), [])
self.assertEqual(send_notifications(), [])
def testNoReadyNotifications(self):
""" We shouldn't see immediate notifications"""
......@@ -161,8 +161,8 @@ class PatchNotificationEmailTest(TestCase):
orig_state = self.patch.state).save()
errors = send_notifications()
self.assertEquals(errors, [])
self.assertEquals(len(mail.outbox), 0)
self.assertEqual(errors, [])
self.assertEqual(len(mail.outbox), 0)
def testNotifications(self):
PatchChangeNotification(patch = self.patch,
......@@ -170,11 +170,11 @@ class PatchNotificationEmailTest(TestCase):
self._expireNotifications()
errors = send_notifications()
self.assertEquals(errors, [])
self.assertEquals(len(mail.outbox), 1)
self.assertEqual(errors, [])
self.assertEqual(len(mail.outbox), 1)
msg = mail.outbox[0]
self.assertEquals(msg.to, [self.submitter.email])
self.assertTrue(self.patch.get_absolute_url() in msg.body)
self.assertEqual(msg.to, [self.submitter.email])
self.assertIn(self.patch.get_absolute_url(), msg.body)
def testNotificationEscaping(self):
self.patch.name = 'Patch name with " character'
......@@ -184,11 +184,11 @@ class PatchNotificationEmailTest(TestCase):
self._expireNotifications()
errors = send_notifications()
self.assertEquals(errors, [])
self.assertEquals(len(mail.outbox), 1)
self.assertEqual(errors, [])
self.assertEqual(len(mail.outbox), 1)
msg = mail.outbox[0]
self.assertEquals(msg.to, [self.submitter.email])
self.assertFalse('&quot;' in msg.body)
self.assertEqual(msg.to, [self.submitter.email])
self.assertNotIn('&quot;', msg.body)
def testNotificationOptout(self):
"""ensure opt-out addresses don't get notifications"""
......@@ -199,8 +199,8 @@ class PatchNotificationEmailTest(TestCase):
EmailOptout(email = self.submitter.email).save()
errors = send_notifications()
self.assertEquals(errors, [])
self.assertEquals(len(mail.outbox), 0)
self.assertEqual(errors, [])
self.assertEqual(len(mail.outbox), 0)
def testNotificationMerge(self):
patches = [self.patch,
......@@ -213,14 +213,14 @@ class PatchNotificationEmailTest(TestCase):
PatchChangeNotification(patch = patch,
orig_state = patch.state).save()
self.assertEquals(PatchChangeNotification.objects.count(), len(patches))
self.assertEqual(PatchChangeNotification.objects.count(), len(patches))
self._expireNotifications()
errors = send_notifications()
self.assertEquals(errors, [])
self.assertEquals(len(mail.outbox), 1)
self.assertEqual(errors, [])
self.assertEqual(len(mail.outbox), 1)
msg = mail.outbox[0]
self.assertTrue(patches[0].get_absolute_url() in msg.body)
self.assertTrue(patches[1].get_absolute_url() in msg.body)
self.assertIn(patches[0].get_absolute_url(), msg.body)
self.assertIn(patches[1].get_absolute_url(), msg.body)
def testUnexpiredNotificationMerge(self):
"""Test that when there are multiple pending notifications, with
......@@ -236,7 +236,7 @@ class PatchNotificationEmailTest(TestCase):
PatchChangeNotification(patch = patch,
orig_state = patch.state).save()
self.assertEquals(PatchChangeNotification.objects.count(), len(patches))
self.assertEqual(PatchChangeNotification.objects.count(), len(patches))
self._expireNotifications()
# update one notification, to bring it out of the notification delay
......@@ -245,15 +245,15 @@ class PatchNotificationEmailTest(TestCase):
# the updated notification should prevent the other from being sent
errors = send_notifications()
self.assertEquals(errors, [])
self.assertEquals(len(mail.outbox), 0)
self.assertEqual(errors, [])
self.assertEqual(len(mail.outbox), 0)