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: 's avatarStephen Finucane <stephen.finucane@intel.com>
Signed-off-by: 's 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)
This diff is collapsed.
......@@ -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)
This diff is collapsed.
......@@ -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)
......@@ -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)
......@@ -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')]))
......
......@@ -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)
......@@ -62,19 +62,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'])
......@@ -82,26 +82,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):
......@@ -117,20 +117,20 @@ class UserPersonConfirmTest(TestCase):