]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
py3: Remove all deprecated UnitTest calls
authorStephen Finucane <stephen.finucane@intel.com>
Sun, 29 Nov 2015 07:35:39 +0000 (07:35 +0000)
committerStephen Finucane <stephen.finucane@intel.com>
Thu, 3 Dec 2015 22:08:58 +0000 (22:08 +0000)
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.

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
14 files changed:
docs/TODO
patchwork/tests/test_bundles.py
patchwork/tests/test_confirm.py
patchwork/tests/test_encodings.py
patchwork/tests/test_filters.py
patchwork/tests/test_mail_settings.py
patchwork/tests/test_notifications.py
patchwork/tests/test_patchparser.py
patchwork/tests/test_person.py
patchwork/tests/test_registration.py
patchwork/tests/test_tags.py
patchwork/tests/test_updates.py
patchwork/tests/test_user.py
patchwork/tests/test_user_browser.py

index 3d41b2a7f7d1e2816d7ca21ad1819375e8721bac..17d8cd17a70796a7fa57931fa3a6aed830af831c 100644 (file)
--- a/docs/TODO
+++ b/docs/TODO
@@ -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
index d5d5d2f36d27a367a6712f7d4337e880f855fd8d..304f5fb514ee6235408f56537bdf3310193de5b9 100644 (file)
@@ -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:
index ba6a095a50c118967e11e6d6d3668150ad0c6397..a56121289622815cfb4480ad92d7458440ee2d50 100644 (file)
@@ -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)
index 252746f5eaa3174b421487ec7b0b0a59066a5ddc..295c48ea119fd60e6d876f21ba0cd27076cbf3f4 100644 (file)
@@ -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):
index c92146babcabb24b489e137e0c36b7f73f21ba20..b2fee90c596c5ed42752c585394905eef3a6dc9e 100644 (file)
@@ -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)
index 39133f91e3075d439b361610a52d00a5ab250850..a1bbde8e7c01bcc078d7ec8545c203a2b2121007 100644 (file)
@@ -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)
index e0cc153adc47abbcaebbd1bcf96040a8159a8ed0..c70f6742b1dadedd3cf474127721a38f90748ad5 100644 (file)
@@ -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)
 
         # expire the updated notification
         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)
index 9f23bf265380ce75e798dbc29e05ec9e1ae0f9f5..3b2248c944ad8da9665786262813d80bd8169925 100644 (file)
@@ -53,13 +53,13 @@ class InlinePatchTest(PatchTest):
         self.assertTrue(self.patch is not None)
 
     def testPatchContent(self):
-        self.assertEquals(self.patch.content, self.orig_patch)
+        self.assertEqual(self.patch.content, self.orig_patch)
 
     def testCommentPresence(self):
         self.assertTrue(self.comment is not None)
 
     def testCommentContent(self):
-        self.assertEquals(self.comment.content, self.test_comment)
+        self.assertEqual(self.comment.content, self.test_comment)
 
 
 class AttachmentPatchTest(InlinePatchTest):
@@ -157,18 +157,18 @@ class SenderEncodingTest(TestCase):
         self.person.delete()
 
     def testName(self):
-        self.assertEquals(self.person.name, self.sender_name)
+        self.assertEqual(self.person.name, self.sender_name)
 
     def testEmail(self):
-        self.assertEquals(self.person.email, self.sender_email)
+        self.assertEqual(self.person.email, self.sender_email)
 
     def testDBQueryName(self):
         db_person = Person.objects.get(name = self.sender_name)
-        self.assertEquals(self.person, db_person)
+        self.assertEqual(self.person, db_person)
 
     def testDBQueryEmail(self):
         db_person = Person.objects.get(email = self.sender_email)
-        self.assertEquals(self.person, db_person)
+        self.assertEqual(self.person, db_person)
 
 
 class SenderUTF8QPEncodingTest(SenderEncodingTest):
@@ -197,7 +197,7 @@ class SubjectEncodingTest(PatchTest):
 
     def testSubjectEncoding(self):
         (patch, comment) = find_content(self.project, self.email)
-        self.assertEquals(patch.name, self.subject)
+        self.assertEqual(patch.name, self.subject)
 
 class SubjectUTF8QPEncodingTest(SubjectEncodingTest):
     subject = u'test s\xfcbject'
@@ -281,8 +281,8 @@ class MultipleProjectPatchTest(TestCase):
         parse_mail(email)
 
     def testParsedProjects(self):
-        self.assertEquals(Patch.objects.filter(project = self.p1).count(), 1)
-        self.assertEquals(Patch.objects.filter(project = self.p2).count(), 1)
+        self.assertEqual(Patch.objects.filter(project = self.p1).count(), 1)
+        self.assertEqual(Patch.objects.filter(project = self.p2).count(), 1)
 
     def tearDown(self):
         self.p1.delete()
@@ -313,7 +313,7 @@ class MultipleProjectPatchCommentTest(MultipleProjectPatchTest):
             patch = Patch.objects.filter(project = project)[0]
             # we should see two comments now - the original mail with the patch,
             # and the one we parsed in setUp()
-            self.assertEquals(Comment.objects.filter(patch = patch).count(), 2)
+            self.assertEqual(Comment.objects.filter(patch = patch).count(), 2)
 
 class ListIdHeaderTest(TestCase):
     """ Test that we parse List-Id headers from mails correctly """
@@ -325,25 +325,25 @@ class ListIdHeaderTest(TestCase):
     def testNoListId(self):
         email = MIMEText('')
         project = find_project_by_header(email)
-        self.assertEquals(project, None)
+        self.assertEqual(project, None)
 
     def testBlankListId(self):
         email = MIMEText('')
         email['List-Id'] = ''
         project = find_project_by_header(email)
-        self.assertEquals(project, None)
+        self.assertEqual(project, None)
 
     def testWhitespaceListId(self):
         email = MIMEText('')
         email['List-Id'] = ' '
         project = find_project_by_header(email)
-        self.assertEquals(project, None)
+        self.assertEqual(project, None)
 
     def testSubstringListId(self):
         email = MIMEText('')
         email['List-Id'] = 'example.com'
         project = find_project_by_header(email)
-        self.assertEquals(project, None)
+        self.assertEqual(project, None)
 
     def testShortListId(self):
         """ Some mailing lists have List-Id headers in short formats, where it
@@ -351,13 +351,13 @@ class ListIdHeaderTest(TestCase):
         email = MIMEText('')
         email['List-Id'] = self.project.listid
         project = find_project_by_header(email)
-        self.assertEquals(project, self.project)
+        self.assertEqual(project, self.project)
 
     def testLongListId(self):
         email = MIMEText('')
         email['List-Id'] = 'Test text <%s>' % self.project.listid
         project = find_project_by_header(email)
-        self.assertEquals(project, self.project)
+        self.assertEqual(project, self.project)
 
     def tearDown(self):
         self.project.delete()
@@ -479,8 +479,8 @@ class DelegateRequestTest(TestCase):
 
     def _assertDelegate(self, delegate):
         query = Patch.objects.filter(project=self.p1)
-        self.assertEquals(query.count(), 1)
-        self.assertEquals(query[0].delegate, delegate)
+        self.assertEqual(query.count(), 1)
+        self.assertEqual(query[0].delegate, delegate)
 
     def testDelegate(self):
         email = self.get_email()
@@ -527,8 +527,8 @@ class InitialPatchStateTest(TestCase):
 
     def _assertState(self, state):
         query = Patch.objects.filter(project=self.p1)
-        self.assertEquals(query.count(), 1)
-        self.assertEquals(query[0].state, state)
+        self.assertEqual(query.count(), 1)
+        self.assertEqual(query[0].state, state)
 
     def testNonDefaultStateIsActuallyNotTheDefaultState(self):
         self.assertNotEqual(self.default_state, self.nondefault_state)
@@ -582,49 +582,49 @@ class ParseInitialTagsTest(PatchTest):
         parse_mail(email)
 
     def testTags(self):
-        self.assertEquals(Patch.objects.count(), 1)
+        self.assertEqual(Patch.objects.count(), 1)
         patch = Patch.objects.all()[0]
-        self.assertEquals(patch.patchtag_set.filter(
+        self.assertEqual(patch.patchtag_set.filter(
                             tag__name='Acked-by').count(), 0)
-        self.assertEquals(patch.patchtag_set.get(
+        self.assertEqual(patch.patchtag_set.get(
                             tag__name='Reviewed-by').count, 1)
-        self.assertEquals(patch.patchtag_set.get(
+        self.assertEqual(patch.patchtag_set.get(
                             tag__name='Tested-by').count, 1)
 
 class PrefixTest(TestCase):
 
     def testSplitPrefixes(self):
-        self.assertEquals(split_prefixes('PATCH'), ['PATCH'])
-        self.assertEquals(split_prefixes('PATCH,RFC'), ['PATCH', 'RFC'])
-        self.assertEquals(split_prefixes(''), [])
-        self.assertEquals(split_prefixes('PATCH,'), ['PATCH'])
-        self.assertEquals(split_prefixes('PATCH '), ['PATCH'])
-        self.assertEquals(split_prefixes('PATCH,RFC'), ['PATCH', 'RFC'])
-        self.assertEquals(split_prefixes('PATCH 1/2'), ['PATCH', '1/2'])
+        self.assertEqual(split_prefixes('PATCH'), ['PATCH'])
+        self.assertEqual(split_prefixes('PATCH,RFC'), ['PATCH', 'RFC'])
+        self.assertEqual(split_prefixes(''), [])
+        self.assertEqual(split_prefixes('PATCH,'), ['PATCH'])
+        self.assertEqual(split_prefixes('PATCH '), ['PATCH'])
+        self.assertEqual(split_prefixes('PATCH,RFC'), ['PATCH', 'RFC'])
+        self.assertEqual(split_prefixes('PATCH 1/2'), ['PATCH', '1/2'])
 
 class SubjectTest(TestCase):
 
     def testCleanSubject(self):
-        self.assertEquals(clean_subject('meep'), 'meep')
-        self.assertEquals(clean_subject('Re: meep'), 'meep')
-        self.assertEquals(clean_subject('[PATCH] meep'), 'meep')
-        self.assertEquals(clean_subject('[PATCH] meep \n meep'), 'meep meep')
-        self.assertEquals(clean_subject('[PATCH RFC] meep'), '[RFC] meep')
-        self.assertEquals(clean_subject('[PATCH,RFC] meep'), '[RFC] meep')
-        self.assertEquals(clean_subject('[PATCH,1/2] meep'), '[1/2] meep')
-        self.assertEquals(clean_subject('[PATCH RFC 1/2] meep'),
+        self.assertEqual(clean_subject('meep'), 'meep')
+        self.assertEqual(clean_subject('Re: meep'), 'meep')
+        self.assertEqual(clean_subject('[PATCH] meep'), 'meep')
+        self.assertEqual(clean_subject('[PATCH] meep \n meep'), 'meep meep')
+        self.assertEqual(clean_subject('[PATCH RFC] meep'), '[RFC] meep')
+        self.assertEqual(clean_subject('[PATCH,RFC] meep'), '[RFC] meep')
+        self.assertEqual(clean_subject('[PATCH,1/2] meep'), '[1/2] meep')
+        self.assertEqual(clean_subject('[PATCH RFC 1/2] meep'),
                                             '[RFC,1/2] meep')
-        self.assertEquals(clean_subject('[PATCH] [RFC] meep'),
+        self.assertEqual(clean_subject('[PATCH] [RFC] meep'),
                                             '[RFC] meep')
-        self.assertEquals(clean_subject('[PATCH] [RFC,1/2] meep'),
+        self.assertEqual(clean_subject('[PATCH] [RFC,1/2] meep'),
                                             '[RFC,1/2] meep')
-        self.assertEquals(clean_subject('[PATCH] [RFC] [1/2] meep'),
+        self.assertEqual(clean_subject('[PATCH] [RFC] [1/2] meep'),
                                             '[RFC,1/2] meep')
-        self.assertEquals(clean_subject('[PATCH] rewrite [a-z] regexes'),
+        self.assertEqual(clean_subject('[PATCH] rewrite [a-z] regexes'),
                                             'rewrite [a-z] regexes')
-        self.assertEquals(clean_subject('[PATCH] [RFC] rewrite [a-z] regexes'),
+        self.assertEqual(clean_subject('[PATCH] [RFC] rewrite [a-z] regexes'),
                                             '[RFC] rewrite [a-z] regexes')
-        self.assertEquals(clean_subject('[foo] [bar] meep', ['foo']),
+        self.assertEqual(clean_subject('[foo] [bar] meep', ['foo']),
                                             '[bar] meep')
-        self.assertEquals(clean_subject('[FOO] [bar] meep', ['foo']),
+        self.assertEqual(clean_subject('[FOO] [bar] meep', ['foo']),
                                             '[bar] meep')
index 9b91115d4005bb607913e5230f819aaa6ca97deb..04251bb330dd6afe823539a5969801311f91a752 100644 (file)
@@ -38,23 +38,23 @@ class SubmitterCompletionTest(TestCase):
 
     def testNameComplete(self):
         response = self.client.get('/submitter/', {'q': 'name'})
-        self.assertEquals(response.status_code, 200)
+        self.assertEqual(response.status_code, 200)
         data = json.loads(response.content.decode())
-        self.assertEquals(len(data), 1)
-        self.assertEquals(data[0]['name'], 'Test Name')
+        self.assertEqual(len(data), 1)
+        self.assertEqual(data[0]['name'], 'Test Name')
 
     def testEmailComplete(self):
         response = self.client.get('/submitter/', {'q': 'test2'})
-        self.assertEquals(response.status_code, 200)
+        self.assertEqual(response.status_code, 200)
         data = json.loads(response.content.decode())
-        self.assertEquals(len(data), 1)
-        self.assertEquals(data[0]['email'], 'test2@example.com')
+        self.assertEqual(len(data), 1)
+        self.assertEqual(data[0]['email'], 'test2@example.com')
 
     def testCompleteLimit(self):
         for i in range(3,10):
             person = Person(email = 'test%d@example.com' % i)
             person.save()
         response = self.client.get('/submitter/', {'q': 'test', 'l': 5})
-        self.assertEquals(response.status_code, 200)
+        self.assertEqual(response.status_code, 200)
         data = json.loads(response.content.decode())
-        self.assertEquals(len(data), 5)
+        self.assertEqual(len(data), 5)
index bf32ae7b3fbeaa1773141db6b80ced077b2e6689..f0e0ba047d6da991d51e24535ebb7841589922a5 100644 (file)
@@ -53,7 +53,7 @@ class RegistrationTest(TestCase):
 
     def testRegistrationForm(self):
         response = self.client.get('/register/')
-        self.assertEquals(response.status_code, 200)
+        self.assertEqual(response.status_code, 200)
         self.assertTemplateUsed(response, 'patchwork/registration_form.html')
 
     def testBlankFields(self):
@@ -61,14 +61,14 @@ class RegistrationTest(TestCase):
             data = self.default_data.copy()
             del data[field]
             response = self.client.post('/register/', data)
-            self.assertEquals(response.status_code, 200)
+            self.assertEqual(response.status_code, 200)
             self.assertFormError(response, 'form', field, self.required_error)
 
     def testInvalidUsername(self):
         data = self.default_data.copy()
         data['username'] = 'invalid user'
         response = self.client.post('/register/', data)
-        self.assertEquals(response.status_code, 200)
+        self.assertEqual(response.status_code, 200)
         self.assertFormError(response, 'form', 'username', self.invalid_error)
 
     def testExistingUsername(self):
@@ -76,7 +76,7 @@ class RegistrationTest(TestCase):
         data = self.default_data.copy()
         data['username'] = user.username
         response = self.client.post('/register/', data)
-        self.assertEquals(response.status_code, 200)
+        self.assertEqual(response.status_code, 200)
         self.assertFormError(response, 'form', 'username',
                 'This username is already taken. Please choose another.')
 
@@ -85,41 +85,41 @@ class RegistrationTest(TestCase):
         data = self.default_data.copy()
         data['email'] = user.email
         response = self.client.post('/register/', data)
-        self.assertEquals(response.status_code, 200)
+        self.assertEqual(response.status_code, 200)
         self.assertFormError(response, 'form', 'email',
                 'This email address is already in use ' + \
                 'for the account "%s".\n' % user.username)
 
     def testValidRegistration(self):
         response = self.client.post('/register/', self.default_data)
-        self.assertEquals(response.status_code, 200)
+        self.assertEqual(response.status_code, 200)
         self.assertContains(response, 'confirmation email has been sent')
 
         # check for presence of an inactive user object
         users = User.objects.filter(username = self.user.username)
-        self.assertEquals(users.count(), 1)
+        self.assertEqual(users.count(), 1)
         user = users[0]
-        self.assertEquals(user.username, self.user.username)
-        self.assertEquals(user.email, self.user.email)
-        self.assertEquals(user.is_active, False)
+        self.assertEqual(user.username, self.user.username)
+        self.assertEqual(user.email, self.user.email)
+        self.assertEqual(user.is_active, False)
 
         # check for confirmation object
         confs = EmailConfirmation.objects.filter(user = user,
                                                  type = 'registration')
-        self.assertEquals(len(confs), 1)
+        self.assertEqual(len(confs), 1)
         conf = confs[0]
-        self.assertEquals(conf.email, self.user.email)
+        self.assertEqual(conf.email, self.user.email)
 
         # check for a sent mail
-        self.assertEquals(len(mail.outbox), 1)
+        self.assertEqual(len(mail.outbox), 1)
         msg = mail.outbox[0]
-        self.assertEquals(msg.subject, 'Patchwork account confirmation')
-        self.assertTrue(self.user.email in msg.to)
-        self.assertTrue(_confirmation_url(conf) in msg.body)
+        self.assertEqual(msg.subject, 'Patchwork account confirmation')
+        self.assertIn(self.user.email, msg.to)
+        self.assertIn(_confirmation_url(conf), msg.body)
 
         # ...and that the URL is valid
         response = self.client.get(_confirmation_url(conf))
-        self.assertEquals(response.status_code, 200)
+        self.assertEqual(response.status_code, 200)
 
 class RegistrationConfirmationTest(TestCase):
 
@@ -134,7 +134,7 @@ class RegistrationConfirmationTest(TestCase):
     def testRegistrationConfirmation(self):
         self.assertEqual(EmailConfirmation.objects.count(), 0)
         response = self.client.post('/register/', self.default_data)
-        self.assertEquals(response.status_code, 200)
+        self.assertEqual(response.status_code, 200)
         self.assertContains(response, 'confirmation email has been sent')
 
         self.assertEqual(EmailConfirmation.objects.count(), 1)
@@ -143,7 +143,7 @@ class RegistrationConfirmationTest(TestCase):
         self.assertTrue(conf.active)
 
         response = self.client.get(_confirmation_url(conf))
-        self.assertEquals(response.status_code, 200)
+        self.assertEqual(response.status_code, 200)
         self.assertTemplateUsed(response, 'patchwork/registration-confirm.html')
 
         conf = EmailConfirmation.objects.get(pk = conf.pk)
@@ -157,19 +157,19 @@ class RegistrationConfirmationTest(TestCase):
         # register
         self.assertEqual(EmailConfirmation.objects.count(), 0)
         response = self.client.post('/register/', self.default_data)
-        self.assertEquals(response.status_code, 200)
+        self.assertEqual(response.status_code, 200)
         self.assertFalse(Person.objects.exists())
 
         # confirm
         conf = EmailConfirmation.objects.filter()[0]
         response = self.client.get(_confirmation_url(conf))
-        self.assertEquals(response.status_code, 200)
+        self.assertEqual(response.status_code, 200)
 
         qs = Person.objects.filter(email = self.user.email)
         self.assertTrue(qs.exists())
         person = Person.objects.get(email = self.user.email)
 
-        self.assertEquals(person.name,
+        self.assertEqual(person.name,
                     self.user.firstname + ' ' + self.user.lastname)
 
     def testRegistrationExistingPersonSetup(self):
@@ -183,16 +183,16 @@ class RegistrationConfirmationTest(TestCase):
         # register
         self.assertEqual(EmailConfirmation.objects.count(), 0)
         response = self.client.post('/register/', self.default_data)
-        self.assertEquals(response.status_code, 200)
+        self.assertEqual(response.status_code, 200)
 
         # confirm
         conf = EmailConfirmation.objects.filter()[0]
         response = self.client.get(_confirmation_url(conf))
-        self.assertEquals(response.status_code, 200)
+        self.assertEqual(response.status_code, 200)
 
         person = Person.objects.get(email = self.user.email)
 
-        self.assertEquals(person.name, fullname)
+        self.assertEqual(person.name, fullname)
 
     def testRegistrationExistingPersonUnmodified(self):
         """ Check that an unconfirmed registration can't modify an existing
@@ -206,8 +206,8 @@ class RegistrationConfirmationTest(TestCase):
         data = self.default_data.copy()
         data['first_name'] = 'invalid'
         data['last_name'] = 'invalid'
-        self.assertEquals(data['email'], person.email)
+        self.assertEqual(data['email'], person.email)
         response = self.client.post('/register/', data)
-        self.assertEquals(response.status_code, 200)
+        self.assertEqual(response.status_code, 200)
 
-        self.assertEquals(Person.objects.get(pk = person.pk).name, fullname)
+        self.assertEqual(Person.objects.get(pk = person.pk).name, fullname)
index 0f7c14f1637f410d757c876c694072bdfb904faa..ebb3ace64cb264befde6317bcd457795a81bd026 100644 (file)
@@ -37,7 +37,7 @@ class ExtractTagsTest(TestCase):
 
     def assertTagsEqual(self, str, acks, reviews, tests):
         counts = extract_tags(str, Tag.objects.all())
-        self.assertEquals((acks, reviews, tests),
+        self.assertEqual((acks, reviews, tests),
                 (counts[Tag.objects.get(name='Acked-by')],
                  counts[Tag.objects.get(name='Reviewed-by')],
                  counts[Tag.objects.get(name='Tested-by')]))
index c9b4f33528cacacae45fc5c82b912ee75b1da4d6..7929f32ed7b965ed6ec9f74d19a9eca82fc3e591 100644 (file)
@@ -88,13 +88,13 @@ class MultipleUpdateTest(TestCase):
         state = State.objects.exclude(pk__in = states)[0]
         self._testStateChange(state.pk)
         for p in self.patches:
-            self.assertEquals(Patch.objects.get(pk = p.pk).state, state)
+            self.assertEqual(Patch.objects.get(pk = p.pk).state, state)
 
     def testStateChangeInvalid(self):
         state = max(State.objects.all().values_list('id', flat = True)) + 1
         orig_states = [patch.state for patch in self.patches]
         response = self._testStateChange(state)
-        self.assertEquals( \
+        self.assertEqual( \
                 [Patch.objects.get(pk = p.pk).state for p in self.patches],
                 orig_states)
         self.assertFormError(response, 'patchform', 'state',
@@ -114,9 +114,9 @@ class MultipleUpdateTest(TestCase):
         delegate = create_maintainer(defaults.project)
         response = self._testDelegateChange(str(delegate.pk))
         for p in self.patches:
-            self.assertEquals(Patch.objects.get(pk = p.pk).delegate, delegate)
+            self.assertEqual(Patch.objects.get(pk = p.pk).delegate, delegate)
 
     def testDelegateClear(self):
         response = self._testDelegateChange('')
         for p in self.patches:
-            self.assertEquals(Patch.objects.get(pk = p.pk).delegate, None)
+            self.assertEqual(Patch.objects.get(pk = p.pk).delegate, None)
index dba8d33b660fccf3ec8c90c397425045101dfd5d..8da4bef986096823c3b44f077c3871e1f8f88d85 100644 (file)
@@ -51,19 +51,19 @@ class UserPersonRequestTest(TestCase):
 
     def testUserPersonRequestForm(self):
         response = self.client.get('/user/link/')
-        self.assertEquals(response.status_code, 200)
+        self.assertEqual(response.status_code, 200)
         self.assertTrue(response.context['linkform'])
 
     def testUserPersonRequestEmpty(self):
         response = self.client.post('/user/link/', {'email': ''})
-        self.assertEquals(response.status_code, 200)
+        self.assertEqual(response.status_code, 200)
         self.assertTrue(response.context['linkform'])
         self.assertFormError(response, 'linkform', 'email',
                 'This field is required.')
 
     def testUserPersonRequestInvalid(self):
         response = self.client.post('/user/link/', {'email': 'foo'})
-        self.assertEquals(response.status_code, 200)
+        self.assertEqual(response.status_code, 200)
         self.assertTrue(response.context['linkform'])
         self.assertFormError(response, 'linkform', 'email',
                                 error_strings['email'])
@@ -71,26 +71,26 @@ class UserPersonRequestTest(TestCase):
     def testUserPersonRequestValid(self):
         response = self.client.post('/user/link/',
                                 {'email': self.user.secondary_email})
-        self.assertEquals(response.status_code, 200)
+        self.assertEqual(response.status_code, 200)
         self.assertTrue(response.context['confirmation'])
 
         # check that we have a confirmation saved
-        self.assertEquals(EmailConfirmation.objects.count(), 1)
+        self.assertEqual(EmailConfirmation.objects.count(), 1)
         conf = EmailConfirmation.objects.all()[0]
-        self.assertEquals(conf.user, self.user.user)
-        self.assertEquals(conf.email, self.user.secondary_email)
-        self.assertEquals(conf.type, 'userperson')
+        self.assertEqual(conf.user, self.user.user)
+        self.assertEqual(conf.email, self.user.secondary_email)
+        self.assertEqual(conf.type, 'userperson')
 
         # check that an email has gone out...
-        self.assertEquals(len(mail.outbox), 1)
+        self.assertEqual(len(mail.outbox), 1)
         msg = mail.outbox[0]
-        self.assertEquals(msg.subject, 'Patchwork email address confirmation')
-        self.assertTrue(self.user.secondary_email in msg.to)
-        self.assertTrue(_confirmation_url(conf) in msg.body)
+        self.assertEqual(msg.subject, 'Patchwork email address confirmation')
+        self.assertIn(self.user.secondary_email, msg.to)
+        self.assertIn(_confirmation_url(conf), msg.body)
 
         # ...and that the URL is valid
         response = self.client.get(_confirmation_url(conf))
-        self.assertEquals(response.status_code, 200)
+        self.assertEqual(response.status_code, 200)
         self.assertTemplateUsed(response, 'patchwork/user-link-confirm.html')
 
 class UserPersonConfirmTest(TestCase):
@@ -106,20 +106,20 @@ class UserPersonConfirmTest(TestCase):
         self.conf.save()
 
     def testUserPersonConfirm(self):
-        self.assertEquals(Person.objects.count(), 0)
+        self.assertEqual(Person.objects.count(), 0)
         response = self.client.get(_confirmation_url(self.conf))
-        self.assertEquals(response.status_code, 200)
+        self.assertEqual(response.status_code, 200)
 
         # check that the Person object has been created and linked
-        self.assertEquals(Person.objects.count(), 1)
+        self.assertEqual(Person.objects.count(), 1)
         person = Person.objects.get(email = self.user.secondary_email)
-        self.assertEquals(person.email, self.user.secondary_email)
-        self.assertEquals(person.user, self.user.user)
+        self.assertEqual(person.email, self.user.secondary_email)
+        self.assertEqual(person.user, self.user.user)
 
         # check that the confirmation has been marked as inactive. We
         # need to reload the confirmation to check this.
         conf = EmailConfirmation.objects.get(pk = self.conf.pk)
-        self.assertEquals(conf.active, False)
+        self.assertEqual(conf.active, False)
 
 class UserLoginRedirectTest(TestCase):
 
@@ -164,7 +164,7 @@ class UserProfileTest(TestCase):
         response = self.client.post('/user/', {'patches_per_page': new_ppp})
 
         user_profile = UserProfile.objects.get(user=self.user.user.id)
-        self.assertEquals(user_profile.patches_per_page, new_ppp)
+        self.assertEqual(user_profile.patches_per_page, new_ppp)
 
     def testUserProfileInvalidPost(self):
         user_profile = UserProfile.objects.get(user=self.user.user.id)
@@ -174,7 +174,7 @@ class UserProfileTest(TestCase):
         response = self.client.post('/user/', {'patches_per_page': new_ppp})
 
         user_profile = UserProfile.objects.get(user=self.user.user.id)
-        self.assertEquals(user_profile.patches_per_page, old_ppp)
+        self.assertEqual(user_profile.patches_per_page, old_ppp)
 
 
 class UserPasswordChangeTest(TestCase):
@@ -241,7 +241,7 @@ class UserUnlinkTest(TestCase):
         self.assertRedirects(response, self.done_url)
 
         person = Person.objects.get(email=user.email)
-        self.assertEquals(person.user, user.user)
+        self.assertEqual(person.user, user.user)
 
     def testUnlinkSecondaryEmail(self):
         user = TestUser()
@@ -258,7 +258,7 @@ class UserUnlinkTest(TestCase):
         self.assertRedirects(response, self.done_url)
 
         person = Person.objects.get(email=user.secondary_email)
-        self.assertEquals(person.user, None)
+        self.assertEqual(person.user, None)
 
     def testUnlinkAnotherUser(self):
         user = TestUser()
@@ -278,7 +278,7 @@ class UserUnlinkTest(TestCase):
         self.assertRedirects(response, self.done_url)
 
         person = Person.objects.get(email=other_user.email)
-        self.assertEquals(person.user, None)
+        self.assertEqual(person.user, None)
 
     def testUnlinkNonPost(self):
         user = TestUser()
@@ -295,4 +295,4 @@ class UserUnlinkTest(TestCase):
         self.assertRedirects(response, self.done_url)
 
         person = Person.objects.get(email=user.secondary_email)
-        self.assertEquals(person.user, user.user)
+        self.assertEqual(person.user, user.user)
index dd6b6c03d54ff67b042bbd77702fbcbe42a04580..5517dc7565eb88493eb58cdf275fb013c3392b7a 100644 (file)
@@ -36,4 +36,4 @@ class LoginTestCase(SeleniumTestCase):
         self.enter_text('password', self.user.password)
         self.click('input[value="Login"]')
         dropdown = self.wait_until_visible('a.dropdown-toggle strong')
-        self.assertEquals(dropdown.text, 'testuser')
+        self.assertEqual(dropdown.text, 'testuser')