← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:py3-BugTaskSearchBugsElsewhereTest into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:py3-BugTaskSearchBugsElsewhereTest into launchpad:master.

Commit message:
Minimally fix BugTaskSearchBugsElsewhereTest for Python 3

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/398886

BugTaskSearchBugsElsewhereTest is only used from lib/lp/bugs/stories/bugs/xx-bugs-advanced-search-upstream-status.txt.  Using a unittest.TestCase from a doctest is pretty dodgy, and on Python 3 the assertEqual method doesn't work.

The ideal fix would be to rewrite the doctest as a unittest, merging this helper class into it along the way.  However, for now, avoiding TestCase methods gets the test working.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-BugTaskSearchBugsElsewhereTest into launchpad:master.
diff --git a/lib/lp/bugs/model/tests/test_bugtask.py b/lib/lp/bugs/model/tests/test_bugtask.py
index 527120e..0a346fa 100644
--- a/lib/lp/bugs/model/tests/test_bugtask.py
+++ b/lib/lp/bugs/model/tests/test_bugtask.py
@@ -1173,8 +1173,11 @@ class BugTaskSearchBugsElsewhereTest(unittest.TestCase):
         # Mark an upstream task on bug #1 "Fix Released"
         bug_one = bugset.get(1)
         firefox_upstream = self._getBugTaskByTarget(bug_one, firefox)
-        self.assertEqual(ServiceUsage.LAUNCHPAD,
-                         firefox_upstream.product.bug_tracking_usage)
+        if (firefox_upstream.product.bug_tracking_usage !=
+                ServiceUsage.LAUNCHPAD):
+            raise AssertionError("%s != %s" % (
+                firefox_upstream.product.bug_tracking_usage,
+                ServiceUsage.LAUNCHPAD))
         self.old_firefox_status = firefox_upstream.status
         firefox_upstream.transitionToStatus(
             BugTaskStatus.FIXRELEASED, getUtility(ILaunchBag).user)
@@ -1195,8 +1198,12 @@ class BugTaskSearchBugsElsewhereTest(unittest.TestCase):
 
         # Get a debbugs watch.
         watch_debbugs_327452 = bugwatchset.get(9)
-        self.assertEqual(watch_debbugs_327452.bugtracker.name, "debbugs")
-        self.assertEqual(watch_debbugs_327452.remotebug, "327452")
+        if watch_debbugs_327452.bugtracker.name != "debbugs":
+            raise AssertionError(
+                "%r != 'debbugs'" % watch_debbugs_327452.bugtracker.name)
+        if watch_debbugs_327452.remotebug != "327452":
+            raise AssertionError(
+                "%r != '327452'" % watch_debbugs_327452.remotebug)
 
         # Associate the watch to a Fix Released task.
         debian = getUtility(IDistributionSet).getByName("debian")