← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:py3-code-exception-modules into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:py3-code-exception-modules into launchpad:master.

Commit message:
lp.code: Use IGNORE_EXCEPTION_MODULE_IN_PYTHON2

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

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

This allows doctests that test tracebacks to work on both Python 2 and 3.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-code-exception-modules into launchpad:master.
diff --git a/lib/lp/code/doc/branch.txt b/lib/lp/code/doc/branch.txt
index 3156008..9f8e8aa 100644
--- a/lib/lp/code/doc/branch.txt
+++ b/lib/lp/code/doc/branch.txt
@@ -120,9 +120,10 @@ are writable, but the owner can be set using the `setOwner` method.
 
     >>> login('admin@xxxxxxxxxxxxx')
     >>> new_branch.registrant = factory.makePerson()
+    ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
     Traceback (most recent call last):
       ...
-    ForbiddenAttribute: ('registrant', <Branch ...>)
+    zope.security.interfaces.ForbiddenAttribute: ('registrant', <Branch ...>)
 
     >>> team = factory.makeTeam(name='new-owner', owner=new_branch.owner)
     >>> new_branch.setOwner(new_owner=team, user=new_branch.owner)
@@ -139,9 +140,10 @@ and -, +, _ and @ are allowed after that.
     >>> namespace.createBranch(
     ...     branch_type=BranchType.HOSTED, name='invalid name!',
     ...     registrant=registrant)
+    ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
     Traceback (most recent call last):
       ...
-    LaunchpadValidationError: Invalid branch name &#x27;invalid name!&#x27;.  Branch ...
+    lp.app.validators.LaunchpadValidationError: Invalid branch name &#x27;invalid name!&#x27;.  Branch ...
 
 
 Determining the recently changed, registered and imported branches
diff --git a/lib/lp/code/doc/codeimport-machine.txt b/lib/lp/code/doc/codeimport-machine.txt
index 685599e..e24d9b6 100644
--- a/lib/lp/code/doc/codeimport-machine.txt
+++ b/lib/lp/code/doc/codeimport-machine.txt
@@ -107,9 +107,10 @@ permitted.
     OFFLINE
 
     >>> new_machine.state = CodeImportMachineState.ONLINE
+    ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
     Traceback (most recent call last):
       ...
-    ForbiddenAttribute: ...
+    zope.security.interfaces.ForbiddenAttribute: ...
 
 Instead, the setOnline() and related methods must be used.  These
 methods update the fields and in addition create events in the
diff --git a/lib/lp/code/doc/codeimport.txt b/lib/lp/code/doc/codeimport.txt
index a95c0a1..bed3223 100644
--- a/lib/lp/code/doc/codeimport.txt
+++ b/lib/lp/code/doc/codeimport.txt
@@ -430,9 +430,10 @@ When you ask for an id that is not present ICodeImportSet.get() raises
 lp.app.errors.NotFoundError, rather than some internal database exception.
 
     >>> code_import_set.get(-10)
+    ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
     Traceback (most recent call last):
       ...
-    NotFoundError: -10
+    lp.app.errors.NotFoundError: -10
 
 
 Canonical URLs
@@ -470,9 +471,10 @@ on those objects.
     >>> print(svn_import.url)
     svn://svn.example.com/trunk
     >>> svn_import.url = 'svn://svn.example.com/branch/1.0'
+    ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
     Traceback (most recent call last):
       ...
-    ForbiddenAttribute: ('url', <CodeImport ...>)
+    zope.security.interfaces.ForbiddenAttribute: ('url', <CodeImport ...>)
 
 Modifications can be done using the CodeImport.updateFromData
 method. If any change were made, this method creates and returns a
@@ -495,9 +497,10 @@ The launchpad.Edit privilege is required to use CodeImport.updateFromData.
 
     >>> login(ANONYMOUS)
     >>> svn_import.updateFromData({}, nopriv)
+    ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
     Traceback (most recent call last):
     ...
-    Unauthorized: (<CodeImport ...>, 'updateFromData', 'launchpad.Moderate')
+    zope.security.interfaces.Unauthorized: (<CodeImport ...>, 'updateFromData', 'launchpad.Moderate')
 
 We saw above how changes to SVN details are displayed in emails above.
 CVS details are displayed in a similar way.
diff --git a/lib/lp/code/stories/branches/xx-branch-edit.txt b/lib/lp/code/stories/branches/xx-branch-edit.txt
index a69fc06..f493201 100644
--- a/lib/lp/code/stories/branches/xx-branch-edit.txt
+++ b/lib/lp/code/stories/branches/xx-branch-edit.txt
@@ -32,8 +32,9 @@ owner, Launchpad administrators or members of the Bazaar Experts team.
     >>> nopriv_browser.open(
     ...     'http://code.launchpad.test/~name12/gnome-terminal/klingon')
     >>> link = nopriv_browser.getLink('Change branch details')
+    ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
     Traceback (most recent call last):
-    LinkNotFoundError
+    zope.testbrowser.browser.LinkNotFoundError
 
     >>> browser = setupBrowser(auth='Basic test@xxxxxxxxxxxxx:test')
     >>> browser.open(
diff --git a/lib/lp/code/stories/branches/xx-branch-reference.txt b/lib/lp/code/stories/branches/xx-branch-reference.txt
index 28784a6..b419da3 100644
--- a/lib/lp/code/stories/branches/xx-branch-reference.txt
+++ b/lib/lp/code/stories/branches/xx-branch-reference.txt
@@ -56,9 +56,10 @@ a 404 error:
 
   >>> anon_browser.open('http://launchpad.test/'
   ...                   'firefox/1.0/.bzr/branch/location')
+  ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
   Traceback (most recent call last):
     ...
-  NotFound: ... u'.bzr'
+  zope.publisher.interfaces.NotFound: ... u'.bzr'
 
 
 Product Branch
@@ -79,6 +80,7 @@ associated with it, we get a 404 error:
 
   >>> anon_browser.open('http://launchpad.test/'
   ...                   'firefox/.bzr/branch/location')
+  ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
   Traceback (most recent call last):
     ...
-  NotFound: ... u'.bzr'
+  zope.publisher.interfaces.NotFound: ... u'.bzr'
diff --git a/lib/lp/code/stories/branches/xx-branchmergeproposals.txt b/lib/lp/code/stories/branches/xx-branchmergeproposals.txt
index 3d48aa0..0220042 100644
--- a/lib/lp/code/stories/branches/xx-branchmergeproposals.txt
+++ b/lib/lp/code/stories/branches/xx-branchmergeproposals.txt
@@ -196,8 +196,9 @@ People not logged in cannot perform reviews.
 
     >>> anon_browser.open(klingon_proposal)
     >>> link = anon_browser.getLink('[Review]')
+    ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
     Traceback (most recent call last):
-    LinkNotFoundError
+    zope.testbrowser.browser.LinkNotFoundError
 
 People who are logged in can perform reviews.
 
@@ -528,18 +529,20 @@ shown for junk branches.
     >>> nopriv_browser.open(
     ...     'http://code.launchpad.test/~mark/+junk/testdoc')
     >>> nopriv_browser.getLink('Propose for merging').click()
+    ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
     Traceback (most recent call last):
     ...
-    LinkNotFoundError
+    zope.testbrowser.browser.LinkNotFoundError
 
 Even if the user hand crafts the URL to look like a proposal to merge,
 they'll get a 404.
 
     >>> nopriv_browser.open(
     ...     'http://code.launchpad.test/~mark/+junk/testdoc/+register-merge')
+    ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
     Traceback (most recent call last):
     ...
-    NotFound: ...
+    zope.publisher.interfaces.NotFound: ...
 
 
 Displaying a preview diff
diff --git a/lib/lp/code/stories/branches/xx-bug-branch-links.txt b/lib/lp/code/stories/branches/xx-bug-branch-links.txt
index 401fff0..f7462e8 100644
--- a/lib/lp/code/stories/branches/xx-bug-branch-links.txt
+++ b/lib/lp/code/stories/branches/xx-bug-branch-links.txt
@@ -19,9 +19,10 @@ if the user is not logged in, they will be asked to log in.
     >>> anon_browser.open(
     ...     'http://code.launchpad.test/~name12/gnome-terminal/klingon')
     >>> anon_browser.getLink('Link a bug report').click()
+    ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
     Traceback (most recent call last):
     ...
-    Unauthorized: (...launchpad.AnyPerson')
+    zope.security.interfaces.Unauthorized: (...launchpad.AnyPerson')
 
     >>> def printBugBranchLinks(browser):
     ...     tags = find_tags_by_class(browser.contents, 'buglink-summary')
@@ -105,9 +106,10 @@ links to a page restricted with the launchpad.AnyPerson permission.
     >>> anon_browser.open(
     ...     'http://launchpad.test/bugs/11')
     >>> anon_browser.getLink('Link a related branch').click()
+    ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
     Traceback (most recent call last):
     ...
-    Unauthorized: (...launchpad.AnyPerson')
+    zope.security.interfaces.Unauthorized: (...launchpad.AnyPerson')
 
     >>> browser.open(
     ...     'http://launchpad.test/bugs/11')
diff --git a/lib/lp/code/stories/branches/xx-code-review-comments.txt b/lib/lp/code/stories/branches/xx-code-review-comments.txt
index 41a2eea..485805b 100644
--- a/lib/lp/code/stories/branches/xx-code-review-comments.txt
+++ b/lib/lp/code/stories/branches/xx-code-review-comments.txt
@@ -54,8 +54,9 @@ The person's name links back to the main site for that person.
 Reply link is displayed even if the user isn't logged in.
 
     >>> anon_browser.getLink('Reply').click()
+    ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
     Traceback (most recent call last):
-    Unauthorized:...
+    zope.security.interfaces.Unauthorized: ...
 
 We can reply to a comment.
 
diff --git a/lib/lp/code/stories/branches/xx-subscribing-branches.txt b/lib/lp/code/stories/branches/xx-subscribing-branches.txt
index c0e69d4..de24148 100644
--- a/lib/lp/code/stories/branches/xx-subscribing-branches.txt
+++ b/lib/lp/code/stories/branches/xx-subscribing-branches.txt
@@ -28,9 +28,10 @@ In order to subscribe to a branch, the user must be logged in.
     >>> anon_browser.open(
     ...     'http://code.launchpad.test/~name12/gnome-terminal/main')
     >>> anon_browser.getLink('Subscribe')
+    ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
     Traceback (most recent call last):
     ...
-    LinkNotFoundError
+    zope.testbrowser.browser.LinkNotFoundError
 
 Let us subscribe to one of the branches. First, let's make sure we can see the
 link "Subscribe" from a branch's page.
@@ -147,9 +148,10 @@ You need to be logged in to see the link.
     >>> anon_browser.open(
     ...     'http://code.launchpad.test/~name12/gnome-terminal/main')
     >>> anon_browser.getLink('Subscribe someone else')
+    ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
     Traceback (most recent call last):
     ...
-    LinkNotFoundError
+    zope.testbrowser.browser.LinkNotFoundError
 
 Any logged in user is able to subscribe others to a branch.
 
diff --git a/lib/lp/code/stories/branches/xx-upgrading-branches.txt b/lib/lp/code/stories/branches/xx-upgrading-branches.txt
index e343fe0..a824a94 100644
--- a/lib/lp/code/stories/branches/xx-upgrading-branches.txt
+++ b/lib/lp/code/stories/branches/xx-upgrading-branches.txt
@@ -32,8 +32,9 @@ Only those with edit permissions on a branch can request an upgrade.
     ...     auth='Basic nopriv@xxxxxxxxxxxxx:test')
     >>> nopriv_browser.open(branch_url)
     >>> link = nopriv_browser.getLink('Upgrade this branch')
+    ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
     Traceback (most recent call last):
-    LinkNotFoundError
+    zope.testbrowser.browser.LinkNotFoundError
 
     >>> domino_browser = setupBrowser(
     ...     auth='Basic fats@xxxxxxxxxx:test')
diff --git a/lib/lp/code/stories/codeimport/xx-create-codeimport.txt b/lib/lp/code/stories/codeimport/xx-create-codeimport.txt
index 99dda4a..474844c 100644
--- a/lib/lp/code/stories/codeimport/xx-create-codeimport.txt
+++ b/lib/lp/code/stories/codeimport/xx-create-codeimport.txt
@@ -32,9 +32,10 @@ link on the main branch listing page for the product.
 
     >>> browser.open('http://code.launchpad.test/firefox')
     >>> browser.getLink('Import a branch').click()
+    ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
     Traceback (most recent call last):
     ...
-    LinkNotFoundError
+    zope.testbrowser.browser.LinkNotFoundError
 
 The owner can configure code hosting for the project and then
 importing will be available to any user.
diff --git a/lib/lp/code/stories/codeimport/xx-edit-codeimport.txt b/lib/lp/code/stories/codeimport/xx-edit-codeimport.txt
index d7a6f77..3643827 100644
--- a/lib/lp/code/stories/codeimport/xx-edit-codeimport.txt
+++ b/lib/lp/code/stories/codeimport/xx-edit-codeimport.txt
@@ -52,9 +52,10 @@ do not get an Edit link.
 Because it's an svn:// URL, it doesn't get linkified:
 
     >>> anon_browser.getLink("svn://svn.example.com/fooix/trunk")
+    ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
     Traceback (most recent call last):
     ...
-    LinkNotFoundError
+    zope.testbrowser.browser.LinkNotFoundError
 
 
 == Not authorized versus 404 ==
@@ -64,12 +65,14 @@ they will get a not authorised page if the branch has a code import,
 and a 404 if the branch doesn't have an import.
 
     >>> anon_browser.open(svn_import_location + '/+edit-import')
+    ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
     Traceback (most recent call last):
-    Unauthorized: (... 'launchpad.Edit')
+    zope.security.interfaces.Unauthorized: (... 'launchpad.Edit')
 
     >>> admin_browser.open(hosted_branch_location + '/+edit-import')
+    ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
     Traceback (most recent call last):
-    NotFoundError
+    lp.app.errors.NotFoundError
 
 
 == Editing details ==