← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:py3-bugs-doctest-unicode-strings-2 into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:py3-bugs-doctest-unicode-strings-2 into launchpad:master.

Commit message:
lp.bugs: Fix u'...' doctest examples for Python 3 (take 2)

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

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

Similar to https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/397612, but I missed a few spots.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-bugs-doctest-unicode-strings-2 into launchpad:master.
diff --git a/lib/lp/bugs/tests/bugs-emailinterface.txt b/lib/lp/bugs/tests/bugs-emailinterface.txt
index 271e77d..91b0af8 100644
--- a/lib/lp/bugs/tests/bugs-emailinterface.txt
+++ b/lib/lp/bugs/tests/bugs-emailinterface.txt
@@ -242,8 +242,8 @@ unfolded before the bug subject is assigned.
     >>> process_email(submit_mail)
     >>> bug = get_latest_added_bug()
 
-    >>> bug.title
-    u'A folded email subject'
+    >>> print(bug.title)
+    A folded email subject
 
 
 Add a comment
@@ -636,8 +636,8 @@ A timestamp and the user that sets the bug private is also recorded:
 
     >>> bug_four.date_made_private
     datetime.datetime(...)
-    >>> bug_four.who_made_private.name
-    u'name12'
+    >>> print(bug_four.who_made_private.name)
+    name12
     >>> bug_attachment.libraryfile.restricted
     True
 
@@ -735,8 +735,9 @@ be subscribed. Examples:
     >>> subscriptions = [subscription.person.name
     ...                  for subscription in bug_four.subscriptions]
     >>> subscriptions.sort()
-    >>> subscriptions
-    [u'name12']
+    >>> for name in subscriptions:
+    ...     print(name)
+    name12
 
 
     >>> submit_commands(bug_four, 'subscribe')
@@ -802,6 +803,7 @@ Unsubscribing from a bug also unsubscribes you from its duplicates. To
 demonstrate, let's first make no_privs an indirect subscriber from bug
 #5, by subscribing them directly to a dupe of bug #5, bug #6.
 
+    >>> from operator import attrgetter
     >>> from lp.registry.interfaces.person import IPersonSet
 
     >>> login("no-priv@xxxxxxxxxxxxx")
@@ -812,16 +814,21 @@ demonstrate, let's first make no_privs an indirect subscriber from bug
     >>> bug_six.duplicateof == bug_five
     True
 
-    >>> sorted([subscriber.displayname
-    ...  for subscriber in bug_five.getIndirectSubscribers()])
-    [u'Sample Person']
+    >>> for subscriber in sorted(
+    ...         bug_five.getIndirectSubscribers(),
+    ...         key=attrgetter('displayname')):
+    ...     print(subscriber.displayname)
+    Sample Person
 
     >>> bug_six.subscribe(no_priv, no_priv)
     <lp.bugs.model.bugsubscription.BugSubscription ...>
 
-    >>> sorted([subscriber.displayname
-    ...  for subscriber in bug_five.getIndirectSubscribers()])
-    [u'No Privileges Person', u'Sample Person']
+    >>> for subscriber in sorted(
+    ...         bug_five.getIndirectSubscribers(),
+    ...         key=attrgetter('displayname')):
+    ...     print(subscriber.displayname)
+    No Privileges Person
+    Sample Person
 
 Now, if we unsubscribe no-priv from bug #5, they will actually get
 unsubscribed from bug #6, thus no longer being indirectly subscribed to
@@ -835,9 +842,11 @@ bug #5.
     >>> bug_six.isSubscribed(no_priv)
     False
 
-    >>> sorted([subscriber.displayname
-    ...  for subscriber in bug_five.getIndirectSubscribers()])
-    [u'Sample Person']
+    >>> for subscriber in sorted(
+    ...         bug_five.getIndirectSubscribers(),
+    ...         key=attrgetter('displayname')):
+    ...     print(subscriber.displayname)
+    Sample Person
 
 (Log back in for the tests that follow.)
 
@@ -968,8 +977,8 @@ bug id.
 The bug id can also be the bug's name.
 
     >>> submit_commands(bug_four, 'duplicate blackhole')
-    >>> bug_four.duplicateof.name
-    u'blackhole'
+    >>> print(bug_four.duplicateof.name)
+    blackhole
 
 An error message is sent if a nonexistent bug id is given.
 
@@ -1209,8 +1218,8 @@ Also like the web UI, we can assign a bug to "me", the current user.
     >>> submit_commands(
     ...     bug_four, 'affects debian',
     ...     'assignee me')
-    >>> debian_task.assignee.name
-    u'name12'
+    >>> print(debian_task.assignee.name)
+    name12
 
 To set which source package the bug affects, we use:
 
diff --git a/lib/lp/bugs/tests/bugtarget-questiontarget.txt b/lib/lp/bugs/tests/bugtarget-questiontarget.txt
index 4e7d564..5a7ae5b 100644
--- a/lib/lp/bugs/tests/bugtarget-questiontarget.txt
+++ b/lib/lp/bugs/tests/bugtarget-questiontarget.txt
@@ -87,14 +87,14 @@ The bug and the question share identical attributes.
     >>> question.datecreated == bug.datecreated
     True
 
-    >>> question.owner.displayname
-    u'No Privileges Person'
+    >>> print(question.owner.displayname)
+    No Privileges Person
 
-    >>> question.title
-    u'Print is broken'
+    >>> print(question.title)
+    Print is broken
 
-    >>> question.description
-    u'Print is broken'
+    >>> print(question.description)
+    Print is broken
 
 The bug's messages are copied to the question. The comment parameter for
 convertToQuestion is optional. When it is provided, it is added to the
@@ -109,8 +109,8 @@ bug.
     >>> question.messages[-1].text_contents == bug.messages[-1].text_contents
     True
 
-    >>> question.messages[-1].text_contents
-    u'This is a question.'
+    >>> print(question.messages[-1].text_contents)
+    This is a question.
 
 Once converted to a question, the bugtask status is Invalid.
 
@@ -164,14 +164,16 @@ just the question created from the bug.
     >>> question in bug.questions
     True
 
-    >>> bug.title
-    u'Print is broken'
+    >>> print(bug.title)
+    Print is broken
 
-    >>> [bug.title for bug in question.bugs]
-    [u'Print is broken']
+    >>> for bug in question.bugs:
+    ...     print(bug.title)
+    Print is broken
 
-    >>> [question.title for question in bug.questions]
-    [u'Print is broken']
+    >>> for question in bug.questions:
+    ...     print(question.title)
+    Print is broken
 
 
 Only one bugtask must be valid
@@ -210,8 +212,8 @@ provided
     True
 
     >>> question = big_bug.convertToQuestion(sample_person)
-    >>> question.title
-    u'Print is borked'
+    >>> print(question.title)
+    Print is borked
 
     >>> len(bugtasks) == len([
     ...     bt for bt in bugtasks if bt.status.title == 'Invalid'])