← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:py3-more-pprint-collection into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:py3-more-pprint-collection into launchpad:master.

Commit message:
Use pprint_collection in more places

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

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

It does a better job of papering over Python 2/3 differences in webservice doctests.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-more-pprint-collection into launchpad:master.
diff --git a/lib/lp/bugs/stories/webservice/xx-bug.txt b/lib/lp/bugs/stories/webservice/xx-bug.txt
index c0c7242..c6611bd 100644
--- a/lib/lp/bugs/stories/webservice/xx-bug.txt
+++ b/lib/lp/bugs/stories/webservice/xx-bug.txt
@@ -561,11 +561,12 @@ It's possible to get a list of similar bugs for a bug task by calling
 its findSimilarBugs() method. As it happens, there aren't any bugs
 similar to bug 1 for Firefox.
 
-    >>> print(anon_webservice.named_get(
+    >>> pprint_collection(anon_webservice.named_get(
     ...     firefox_bugtask['self_link'],
-    ...     'findSimilarBugs'))
-    HTTP/1.1 200 Ok...
-    {"total_size": 0, "start": 0, "entries": []}
+    ...     'findSimilarBugs').jsonBody())
+    start: 0
+    total_size: 0
+    ---
 
 If we add a new bug that's quite similar to others, findSimilarBugs()
 will return something more useful.
@@ -580,15 +581,33 @@ will return something more useful.
     ...     webservice.getAbsoluteUrl('/firefox/+bug/%s' % new_bug['id'])
     ...     ).jsonBody()
 
-    >>> print(anon_webservice.named_get(
+    >>> pprint_collection(anon_webservice.named_get(
     ...     new_bug_task['self_link'],
-    ...     'findSimilarBugs'))
-    HTTP/1.1 200 Ok...
-    {"total_size": 4, "start": 0, "entries":...
-    "id": 1... "title": "Firefox does not support SVG"...
-    "id": 4... "title": "Reflow problems with complex page layouts"...
-    "id": 5... "title": "Firefox install instructions should be complete"...
-    "id": ...  "title": "Test bug"...
+    ...     'findSimilarBugs').jsonBody())
+    start: 0
+    total_size: 4
+    ---
+    ...
+    id: 1
+    ...
+    title: 'Firefox does not support SVG'
+    ...
+    ---
+    ...
+    id: 4
+    ...
+    title: 'Reflow problems with complex page layouts'
+    ...
+    ---
+    ...
+    id: 5
+    ...
+    title: 'Firefox install instructions should be complete'
+    ...
+    ---
+    ...
+    title: 'Test bug'
+    ...
 
 
 Bug nominations
diff --git a/lib/lp/registry/stories/webservice/xx-private-team.txt b/lib/lp/registry/stories/webservice/xx-private-team.txt
index 182e367..44a63db 100644
--- a/lib/lp/registry/stories/webservice/xx-private-team.txt
+++ b/lib/lp/registry/stories/webservice/xx-private-team.txt
@@ -21,31 +21,33 @@ even exists.
     >>> transaction.commit()
     >>> logout()
 
+    >>> from lazr.restful.testing.webservice import pprint_collection
+
     # XXX: 2008-08-01, salgado: Notice how the total_size is incorrect here.
     # That ought to be fixed at some point.
     >>> member = user_webservice.get("/~private-team-owner").jsonBody()
     >>> response = user_webservice.get(
     ...     member['memberships_details_collection_link'])
-    >>> print(sorted(response.jsonBody().items()))
-    [(u'entries', []),
-     (u'resource_type_link',
-      u'http://.../#team_membership-page-resource'),
-     (u'start', 0),
-     (u'total_size', 1)]
+    >>> pprint_collection(response.jsonBody())
+    resource_type_link: 'http://.../#team_membership-page-resource'
+    start: 0
+    total_size: 1
+    ---
 
     Salgado can see the team since he's a Launchpad admin.
 
     >>> member = webservice.get("/~private-team-owner").jsonBody()
     >>> response = webservice.get(
     ...     member['memberships_details_collection_link'])
-    >>> print(sorted(response.jsonBody().items()))
-    [(u'entries',
-      [{u'status': u'Administrator',...
-        u'team_link': u'http://.../~private-team'...
-     (u'resource_type_link',
-      u'http://.../#team_membership-page-resource'),
-     (u'start', 0),
-     (u'total_size', 1)]
+    >>> pprint_collection(response.jsonBody())
+    resource_type_link: 'http://.../#team_membership-page-resource'
+    start: 0
+    total_size: 1
+    ---
+    ...
+    status: 'Administrator'
+    team_link: 'http://.../~private-team'
+    ...
 
 Similarly, when a public team is a sub-team of a private team, non-members
 cannot see the private team in the public team's super_team's attribute.