launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #00182
[Merge] lp:~jtv/launchpad/test-cruft-bugs into lp:launchpad/devel
Jeroen T. Vermeulen has proposed merging lp:~jtv/launchpad/test-cruft-bugs into lp:launchpad/devel.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers): code
= Bugs test cruft =
This removes some boilerplate in unit tests that's no longer needed. It also fixes the "make lint" output I got for the tests I changed.
To test,
{{{
./bin/test -vvc -m lp.bugs
}}}
Jeroen
--
https://code.launchpad.net/~jtv/launchpad/test-cruft-bugs/+merge/30439
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jtv/launchpad/test-cruft-bugs into lp:launchpad/devel.
=== modified file 'lib/lp/bugs/browser/tests/test_breadcrumbs.py'
--- lib/lp/bugs/browser/tests/test_breadcrumbs.py 2010-04-28 10:13:00 +0000
+++ lib/lp/bugs/browser/tests/test_breadcrumbs.py 2010-07-20 17:01:21 +0000
@@ -1,10 +1,8 @@
-# Copyright 2009 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
__metaclass__ = type
-import unittest
-
from zope.component import getUtility
from canonical.launchpad.webapp.publisher import canonical_url
@@ -31,7 +29,8 @@
self.assertEquals("Bug #%d" % self.bug.id, last_crumb.text)
def test_bugtask_child(self):
- crumbs = self.getBreadcrumbsForObject(self.bugtask, view_name='+activity')
+ crumbs = self.getBreadcrumbsForObject(
+ self.bugtask, view_name='+activity')
self.assertEquals(crumbs[-1].url, "%s/+activity" % self.bugtask_url)
self.assertEquals(crumbs[-2].url, self.bugtask_url)
self.assertEquals(crumbs[-2].text, "Bug #%d" % self.bug.id)
@@ -47,7 +46,8 @@
('Bug #%s' % self.bug.id,
'http://bugs.launchpad.dev/crumb-tester/+bug/%s' % self.bug.id),
('Comment #1',
- 'http://bugs.launchpad.dev/crumb-tester/+bug/%s/comments/1' % self.bug.id),
+ 'http://bugs.launchpad.dev/crumb-tester/+bug/%s/comments/1' % (
+ self.bug.id)),
]
self.assertBreadcrumbs(expected_breadcrumbs, comment)
@@ -78,7 +78,3 @@
(self.bug_tracker.title, self.bug_tracker_url),
]
self.assertBreadcrumbs(expected_breadcrumbs, self.bug_tracker)
-
-
-def test_suite():
- return unittest.TestLoader().loadTestsFromName(__name__)
=== modified file 'lib/lp/bugs/browser/tests/test_bugbranch.py'
--- lib/lp/bugs/browser/tests/test_bugbranch.py 2009-07-17 00:26:05 +0000
+++ lib/lp/bugs/browser/tests/test_bugbranch.py 2010-07-20 17:01:21 +0000
@@ -1,12 +1,10 @@
-# Copyright 2009 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Unit tests for BugBranches."""
__metaclass__ = type
-import unittest
-
from lp.testing import login_person, TestCaseWithFactory
from canonical.launchpad.webapp.interfaces import IPrimaryContext
from canonical.testing import DatabaseFunctionalLayer
@@ -27,7 +25,3 @@
self.assertEqual(
IPrimaryContext(bugbranch).context,
IPrimaryContext(bugbranch.branch).context)
-
-
-def test_suite():
- return unittest.TestLoader().loadTestsFromName(__name__)
=== modified file 'lib/lp/bugs/browser/tests/test_bugsupervisor.py'
--- lib/lp/bugs/browser/tests/test_bugsupervisor.py 2010-07-14 15:42:40 +0000
+++ lib/lp/bugs/browser/tests/test_bugsupervisor.py 2010-07-20 17:01:21 +0000
@@ -5,8 +5,6 @@
__metaclass__ = type
-import unittest
-
from zope.app.form.interfaces import ConversionError
from lp.bugs.browser.bugsupervisor import BugSupervisorEditSchema
@@ -173,7 +171,3 @@
self.product, name='+bugsupervisor', form=form)
self.assertEqual([], view.errors)
self.assertEqual(private_team, self.product.bug_supervisor)
-
-
-def test_suite():
- return unittest.TestLoader().loadTestsFromName(__name__)
=== modified file 'lib/lp/bugs/browser/tests/test_bugtarget_configure.py'
--- lib/lp/bugs/browser/tests/test_bugtarget_configure.py 2010-06-18 00:46:17 +0000
+++ lib/lp/bugs/browser/tests/test_bugtarget_configure.py 2010-07-20 17:01:21 +0000
@@ -5,8 +5,6 @@
__metaclass__ = type
-import unittest
-
from lp.testing import login_person, TestCaseWithFactory
from lp.testing.views import create_initialized_view
from canonical.testing import DatabaseFunctionalLayer
@@ -121,7 +119,3 @@
self.product, name='+configure-bugtracker', form=form)
self.assertEqual([], view.errors)
self.assertFalse(self.product.enable_bug_expiration)
-
-
-def test_suite():
- return unittest.TestLoader().loadTestsFromName(__name__)
=== modified file 'lib/lp/bugs/browser/tests/test_distribution_upstream_bug_report.py'
--- lib/lp/bugs/browser/tests/test_distribution_upstream_bug_report.py 2009-06-25 00:40:31 +0000
+++ lib/lp/bugs/browser/tests/test_distribution_upstream_bug_report.py 2010-07-20 17:01:21 +0000
@@ -43,7 +43,7 @@
# a tuple in the form (sort_key, reversed).
view_sort_key, view_sort_reversed = view.sort_order
self.assertEqual(view_sort_key, sort_key,
- "Expected a sort_key of '%s', got '%s'" %
+ "Expected a sort_key of '%s', got '%s'" %
(sort_key, view_sort_key))
# By default, reversed is False.
@@ -67,7 +67,3 @@
self.assertTrue(view_sort_reversed,
"Sort order should be reversed for a sort_by value of "
"%s" % reversed_key)
-
-
-def test_suite():
- return unittest.TestLoader().loadTestsFromName(__name__)
=== modified file 'lib/lp/bugs/browser/tests/test_securitycontact.py'
--- lib/lp/bugs/browser/tests/test_securitycontact.py 2010-05-25 20:36:49 +0000
+++ lib/lp/bugs/browser/tests/test_securitycontact.py 2010-07-20 17:01:21 +0000
@@ -1,12 +1,10 @@
-# Copyright10 Canonical Ltd. This software is licensed under the
+# Copyright 2010 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version (see the file LICENSE).
"""Unit tests for security contact views."""
__metaclass__ = type
-import unittest
-
from zope.app.form.interfaces import ConversionError
from lp.testing import login, login_person, TestCaseWithFactory
@@ -148,7 +146,3 @@
self.product, name='+securitycontact', form=form)
self.assertEqual([], view.errors)
self.assertEqual(another_team, self.product.security_contact)
-
-
-def test_suite():
- return unittest.TestLoader().loadTestsFromName(__name__)
=== modified file 'lib/lp/bugs/tests/test_apportjob.py'
--- lib/lp/bugs/tests/test_apportjob.py 2010-05-28 02:08:50 +0000
+++ lib/lp/bugs/tests/test_apportjob.py 2010-07-20 17:01:21 +0000
@@ -7,7 +7,6 @@
import os
import transaction
-import unittest
from sqlobject import SQLObjectNotFound
@@ -213,24 +212,22 @@
# IProcessApportBlobJobSource.create() will create only one
# ProcessApportBlobJob for a given BLOB, no matter how many
# times it is called.
- current_jobs = list(
- getUtility(IProcessApportBlobJobSource).iterReady())
+ blobjobsource = getUtility(IProcessApportBlobJobSource)
+ current_jobs = list(blobjobsource.iterReady())
self.assertEqual(
0, len(current_jobs),
"There should be no ProcessApportBlobJobs. Found %s" %
len(current_jobs))
- job = getUtility(IProcessApportBlobJobSource).create(self.blob)
- current_jobs = list(
- getUtility(IProcessApportBlobJobSource).iterReady())
+ job = blobjobsource.create(self.blob)
+ current_jobs = list(blobjobsource.iterReady())
self.assertEqual(
1, len(current_jobs),
"There should be only one ProcessApportBlobJob. Found %s" %
len(current_jobs))
- another_job = getUtility(IProcessApportBlobJobSource).create(self.blob)
- current_jobs = list(
- getUtility(IProcessApportBlobJobSource).iterReady())
+ another_job = blobjobsource.create(self.blob)
+ current_jobs = list(blobjobsource.iterReady())
self.assertEqual(
1, len(current_jobs),
"There should be only one ProcessApportBlobJob. Found %s" %
@@ -242,17 +239,14 @@
# IProcessApportBlobJobSource.
job.job.start()
job.job.complete()
- current_jobs = list(
- getUtility(IProcessApportBlobJobSource).iterReady())
+ current_jobs = list(blobjobsource.iterReady())
self.assertEqual(
0, len(current_jobs),
"There should be no ready ProcessApportBlobJobs. Found %s" %
len(current_jobs))
- yet_another_job = getUtility(
- IProcessApportBlobJobSource).create(self.blob)
- current_jobs = list(
- getUtility(IProcessApportBlobJobSource).iterReady())
+ yet_another_job = blobjobsource.create(self.blob)
+ current_jobs = list(blobjobsource.iterReady())
self.assertEqual(
0, len(current_jobs),
"There should be no new ProcessApportBlobJobs. Found %s" %
@@ -446,7 +440,3 @@
view.extra_data_to_process,
"view.extra_data_to_process should be False when there is no "
"job.")
-
-
-def test_suite():
- return unittest.TestLoader().loadTestsFromName(__name__)
=== modified file 'lib/lp/bugs/tests/test_bug_messages.py'
--- lib/lp/bugs/tests/test_bug_messages.py 2009-12-01 12:35:28 +0000
+++ lib/lp/bugs/tests/test_bug_messages.py 2010-07-20 17:01:21 +0000
@@ -1,13 +1,10 @@
-
-# Copyright 2009 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Webservice unit tests related to Launchpad Bugs."""
__metaclass__ = type
-import unittest
-
from canonical.launchpad.ftests import login
from canonical.testing import DatabaseFunctionalLayer
@@ -39,6 +36,3 @@
# IIndexedMessage.
for indexed_message in self.bug_2.indexed_messages:
self.failUnlessEqual(None, indexed_message.parent)
-
-def test_suite():
- return unittest.TestLoader().loadTestsFromName(__name__)
=== modified file 'lib/lp/bugs/tests/test_bugchanges.py'
--- lib/lp/bugs/tests/test_bugchanges.py 2010-06-23 01:15:11 +0000
+++ lib/lp/bugs/tests/test_bugchanges.py 2010-07-20 17:01:21 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Tests for recording changes done to a bug."""
@@ -746,7 +746,7 @@
' Importance: %s\n'
' Status: %s' % (
target.bugtargetname, added_task.importance.title,
- added_task.status.title))
+ added_task.status.title)),
}
self.assertRecordedChange(
@@ -776,7 +776,7 @@
' Status: %s' % (
target.bugtargetname, added_task.importance.title,
added_task.assignee.displayname, added_task.assignee.name,
- added_task.status.title))
+ added_task.status.title)),
}
self.assertRecordedChange(
@@ -807,7 +807,7 @@
' Importance: %s\n'
' Status: %s' % (
target.bugtargetname, bug_watch.url,
- added_task.importance.title, added_task.status.title))
+ added_task.importance.title, added_task.status.title)),
}
self.assertRecordedChange(
@@ -1498,7 +1498,7 @@
'person': self.user,
'text': (
'** Converted to question:\n'
- ' %s' % canonical_url(converted_question))
+ ' %s' % canonical_url(converted_question)),
}
status_notification = {
'text': (
@@ -1537,7 +1537,3 @@
expected_activity=expected_activity,
expected_notification=expected_notification,
bug=new_bug)
-
-
-def test_suite():
- return unittest.TestLoader().loadTestsFromName(__name__)
=== modified file 'lib/lp/bugs/tests/test_bugheat.py'
--- lib/lp/bugs/tests/test_bugheat.py 2010-06-22 16:08:05 +0000
+++ lib/lp/bugs/tests/test_bugheat.py 2010-07-20 17:01:21 +0000
@@ -61,8 +61,8 @@
def setUp(self):
self.target = self.factory.makeDistributionSourcePackage()
-class DistributionSourcePackageNullBugHeatCacheTest(
- TestCaseWithFactory):
+
+class DistributionSourcePackageNullBugHeatCacheTest(TestCaseWithFactory):
"""Ensure distro source package cache values start at None."""
layer = LaunchpadZopelessLayer
@@ -174,6 +174,3 @@
def setUp(self):
self.target = self.factory.makeProject()
-
-def test_suite():
- return unittest.TestLoader().loadTestsFromName(__name__)
=== modified file 'lib/lp/bugs/tests/test_bugjob.py'
--- lib/lp/bugs/tests/test_bugjob.py 2010-01-21 17:47:38 +0000
+++ lib/lp/bugs/tests/test_bugjob.py 2010-07-20 17:01:21 +0000
@@ -5,8 +5,6 @@
__metaclass__ = type
-import unittest
-
from canonical.testing import LaunchpadZopelessLayer
from lp.bugs.interfaces.bugjob import BugJobType
@@ -49,7 +47,3 @@
bug = self.factory.makeBug()
self.assertRaises(
AttributeError, BugJobDerived.create, bug)
-
-
-def test_suite():
- return unittest.TestLoader().loadTestsFromName(__name__)
=== modified file 'lib/lp/bugs/tests/test_bugnomination.py'
--- lib/lp/bugs/tests/test_bugnomination.py 2009-08-26 10:55:47 +0000
+++ lib/lp/bugs/tests/test_bugnomination.py 2010-07-20 17:01:21 +0000
@@ -1,12 +1,10 @@
-# Copyright 2009 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Tests related to bug nominations."""
__metaclass__ = type
-import unittest
-
from canonical.launchpad.ftests import login, logout
from canonical.testing import DatabaseFunctionalLayer
from lp.testing import TestCaseWithFactory
@@ -98,7 +96,3 @@
sp_bug.addTask(
self.eric, self.series.distribution.getSourcePackage(spn))
self.assertTrue(sp_bug.canBeNominatedFor(self.series))
-
-
-def test_suite():
- return unittest.TestLoader().loadTestsFromName(__name__)
=== modified file 'lib/lp/bugs/tests/test_bugnotification.py'
--- lib/lp/bugs/tests/test_bugnotification.py 2010-06-03 13:53:29 +0000
+++ lib/lp/bugs/tests/test_bugnotification.py 2010-07-20 17:01:21 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Tests related to bug notifications."""
@@ -198,8 +198,3 @@
recipient.person
for recipient in latest_notification.recipients)
self.assertEqual(self.dupe_subscribers, recipients)
-
-
-def test_suite():
- """Return the test suite for the tests in this module."""
- return unittest.TestLoader().loadTestsFromName(__name__)
=== modified file 'lib/lp/bugs/tests/test_bugs_webservice.py'
--- lib/lp/bugs/tests/test_bugs_webservice.py 2010-05-20 09:15:37 +0000
+++ lib/lp/bugs/tests/test_bugs_webservice.py 2010-07-20 17:01:21 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Webservice unit tests related to Launchpad Bugs."""
@@ -6,7 +6,6 @@
__metaclass__ = type
import re
-import unittest
from BeautifulSoup import BeautifulSoup
from simplejson import dumps
@@ -201,7 +200,3 @@
self.failUnlessEqual(200, response.status)
finally:
snapshot.HARD_LIMIT_FOR_SNAPSHOT = real_hard_limit_for_snapshot
-
-
-def test_suite():
- return unittest.TestLoader().loadTestsFromName(__name__)
=== modified file 'lib/lp/bugs/tests/test_bugtask_1.py'
--- lib/lp/bugs/tests/test_bugtask_1.py 2010-04-16 15:06:55 +0000
+++ lib/lp/bugs/tests/test_bugtask_1.py 2010-07-20 17:01:21 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Bugtask related tests that are too complex to be readable as doctests."""
@@ -165,7 +165,6 @@
'Bugtask %s on %s has no resolved related tasks.' % (
bugtask.id, bugtask.target.displayname))
-
def assertBugTaskIsOpenUpstream(self, bugtask):
"""Make sure at least one of the related upstream tasks is open.
@@ -333,8 +332,3 @@
# empty dictionary.
bugs_and_tasks = getUtility(IBugTaskSet).getBugTasks([])
self.failUnlessEqual(bugs_and_tasks, {})
-
-
-def test_suite():
- return unittest.TestLoader().loadTestsFromName(__name__)
-
=== modified file 'lib/lp/bugs/tests/test_bugtracker_vocabulary.py'
--- lib/lp/bugs/tests/test_bugtracker_vocabulary.py 2010-06-16 15:59:53 +0000
+++ lib/lp/bugs/tests/test_bugtracker_vocabulary.py 2010-07-20 17:01:21 +0000
@@ -5,8 +5,6 @@
__metaclass__ = type
-from unittest import TestLoader
-
from zope.schema.vocabulary import getVocabularyRegistry
from canonical.launchpad.ftests import login, login_person
@@ -117,7 +115,3 @@
self.assertEqual([], bug_trackers)
self.assertRaises(
LookupError, self.vocab.getTermByToken, 'marten')
-
-
-def test_suite():
- return TestLoader().loadTestsFromName(__name__)
=== modified file 'lib/lp/bugs/tests/test_bugwatch.py'
--- lib/lp/bugs/tests/test_bugwatch.py 2010-04-30 03:10:17 +0000
+++ lib/lp/bugs/tests/test_bugwatch.py 2010-07-20 17:01:21 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Tests for BugWatchSet."""
@@ -174,6 +174,7 @@
# bugs.debian.org is already registered, so no dice.
pass
+
class SFExtractBugTrackerAndBugTest(
ExtractBugTrackerAndBugTestBase, unittest.TestCase):
"""Ensure BugWatchSet.extractBugTrackerAndBug works with SF URLs.
@@ -657,7 +658,3 @@
messages = [activity.message for activity in self.bug_watch.activity]
for i in range(MAX_SAMPLE_SIZE):
self.failUnless("Activity %s" % i in messages)
-
-
-def test_suite():
- return unittest.TestLoader().loadTestsFromName(__name__)
Follow ups