Merge ~cjwatson/launchpad:py3-test-repr-long into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 07a48e66bf8c12fccac75504de00467874ea194d
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:py3-test-repr-long
Merge into: launchpad:master
Diff against target: 256 lines (+74/-38)
8 files modified
lib/lp/bugs/doc/bugsummary.txt (+3/-3)
lib/lp/bugs/scripts/tests/test_bugsummaryrebuild.py (+5/-1)
lib/lp/buildmaster/doc/builder.txt (+15/-6)
lib/lp/registry/browser/tests/poll-views_0.txt (+6/-6)
lib/lp/registry/doc/poll.txt (+6/-6)
lib/lp/soyuz/browser/tests/archive-views.txt (+26/-10)
lib/lp/soyuz/doc/publishing.txt (+8/-4)
lib/lp/testing/systemdocs.py (+5/-2)
Reviewer Review Type Date Requested Status
Thiago F. Pappacena (community) Approve
Review via email: mp+397339@code.launchpad.net

Commit message

Adjust tests for repr of (long) integers in Python 3

To post a comment you must log in.
Revision history for this message
Thiago F. Pappacena (pappacena) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/bugs/doc/bugsummary.txt b/lib/lp/bugs/doc/bugsummary.txt
2index 77299eb..1709e10 100644
3--- a/lib/lp/bugs/doc/bugsummary.txt
4+++ b/lib/lp/bugs/doc/bugsummary.txt
5@@ -370,15 +370,15 @@ a sourcepackage, so we subtract this count from the total number of bugs
6 targeted to the distribution:
7
8 >>> from storm.expr import SQL
9- >>> store.find(
10+ >>> print(store.find(
11 ... BugSummary,
12 ... BugSummary.distribution == distribution,
13 ... BugSummary.status == BugTaskStatus.CONFIRMED,
14 ... BugSummary.viewed_by == None,
15 ... BugSummary.tag == None).sum(SQL("""
16 ... CASE WHEN sourcepackagename IS NULL THEN count ELSE -count END
17- ... """)) or 0
18- 1L
19+ ... """)) or 0)
20+ 1
21
22
23 DistroSeries Bug Counts
24diff --git a/lib/lp/bugs/scripts/tests/test_bugsummaryrebuild.py b/lib/lp/bugs/scripts/tests/test_bugsummaryrebuild.py
25index 7c246c1..b384550 100644
26--- a/lib/lp/bugs/scripts/tests/test_bugsummaryrebuild.py
27+++ b/lib/lp/bugs/scripts/tests/test_bugsummaryrebuild.py
28@@ -3,6 +3,8 @@
29
30 __metaclass__ = type
31
32+import sys
33+
34 from testtools.content import text_content
35 from testtools.matchers import MatchesRegex
36 import transaction
37@@ -139,10 +141,12 @@ class TestBugSummaryRebuild(TestCaseWithFactory):
38 rebuild_bugsummary_for_target(product, log)
39 self.assertEqual(1, get_bugsummary_rows(product).count())
40 self.assertEqual(0, get_bugsummaryjournal_rows(product).count())
41+ long_type = int if sys.version_info[0] >= 3 else long
42 self.assertThat(
43 log.getLogBufferAndClear(),
44 MatchesRegex(
45- 'DEBUG Rebuilding %s\nDEBUG Added {.*: 1L}' % product.name))
46+ 'DEBUG Rebuilding %s\nDEBUG Added {.*: %r}' %
47+ (product.name, long_type(1))))
48
49 def test_script(self):
50 product = self.factory.makeProduct()
51diff --git a/lib/lp/buildmaster/doc/builder.txt b/lib/lp/buildmaster/doc/builder.txt
52index 51c039d..e3620e9 100644
53--- a/lib/lp/buildmaster/doc/builder.txt
54+++ b/lib/lp/buildmaster/doc/builder.txt
55@@ -98,8 +98,11 @@ virtualization status, architecture, then name.
56 Processor/virtualization.
57
58 >>> queue_sizes = builderset.getBuildQueueSizes()
59- >>> queue_sizes['nonvirt']['386']
60- (1L, datetime.timedelta(0, 60))
61+ >>> size, duration = queue_sizes['nonvirt']['386']
62+ >>> print(size)
63+ 1
64+ >>> print(duration)
65+ 0:01:00
66
67 There are no 'amd64' build queue entries.
68
69@@ -142,8 +145,11 @@ Let's re-enable the ubuntu primary archive.
70 The build for the ubuntu primary archive shows up again.
71
72 >>> queue_sizes = builderset.getBuildQueueSizes()
73- >>> queue_sizes['nonvirt']['386']
74- (1L, datetime.timedelta(0, 60))
75+ >>> size, duration = queue_sizes['nonvirt']['386']
76+ >>> print(size)
77+ 1
78+ >>> print(duration)
79+ 0:01:00
80
81 All job types are included. If we create a recipe build job, it will
82 show up in the calculated queue size.
83@@ -152,5 +158,8 @@ show up in the calculated queue size.
84 ... distroseries=ubuntu.currentseries).queueBuild()
85 >>> transaction.commit()
86 >>> queue_sizes = builderset.getBuildQueueSizes()
87- >>> print(queue_sizes['virt']['386'])
88- (1L, datetime.timedelta(0, 600))
89+ >>> size, duration = queue_sizes['virt']['386']
90+ >>> print(size)
91+ 1
92+ >>> print(duration)
93+ 0:10:00
94diff --git a/lib/lp/registry/browser/tests/poll-views_0.txt b/lib/lp/registry/browser/tests/poll-views_0.txt
95index 47ab535..2048cb1 100644
96--- a/lib/lp/registry/browser/tests/poll-views_0.txt
97+++ b/lib/lp/registry/browser/tests/poll-views_0.txt
98@@ -65,12 +65,12 @@ matrix as a python list, with the necessary headers (the option's names).
99
100 >>> poll_results = getMultiAdapter((poll, TestRequest()), name="+index")
101 >>> for row in poll_results.getPairwiseMatrixWithHeaders():
102- ... print(row)
103- [None, u'A', u'B', u'C', u'D']
104- [u'A', None, 2L, 2L, 2L]
105- [u'B', 2L, None, 2L, 2L]
106- [u'C', 1L, 1L, None, 1L]
107- [u'D', 2L, 1L, 2L, None]
108+ ... print(pretty(row))
109+ [None, 'A', 'B', 'C', 'D']
110+ ['A', None, 2, 2, 2]
111+ ['B', 2, None, 2, 2]
112+ ['C', 1, 1, None, 1]
113+ ['D', 2, 1, 2, None]
114
115 == Voting on closed polls ==
116
117diff --git a/lib/lp/registry/doc/poll.txt b/lib/lp/registry/doc/poll.txt
118index 6ef79a1..b1ef334 100644
119--- a/lib/lp/registry/doc/poll.txt
120+++ b/lib/lp/registry/doc/poll.txt
121@@ -131,10 +131,10 @@ people can start voting.
122 >>> votes = poll2.storeCondorcetVote(member3, options, when=opendate)
123 >>> options = {a: 1}
124 >>> votes = poll2.storeCondorcetVote(member4, options, when=opendate)
125+ >>> from zope.security.proxy import removeSecurityProxy
126 >>> for row in poll2.getPairwiseMatrix():
127- ... print row
128- [None, 2L, 2L, 2L]
129- [2L, None, 2L, 2L]
130- [1L, 1L, None, 1L]
131- [2L, 1L, 2L, None]
132-
133+ ... print(pretty(removeSecurityProxy(row)))
134+ [None, 2, 2, 2]
135+ [2, None, 2, 2]
136+ [1, 1, None, 1]
137+ [2, 1, 2, None]
138diff --git a/lib/lp/soyuz/browser/tests/archive-views.txt b/lib/lp/soyuz/browser/tests/archive-views.txt
139index e27c6d6..ed0598a 100644
140--- a/lib/lp/soyuz/browser/tests/archive-views.txt
141+++ b/lib/lp/soyuz/browser/tests/archive-views.txt
142@@ -60,8 +60,12 @@ The ArchiveView provides the html for the inline description editing widget.
143 For convenience the ArchiveView also includes a build_counters property
144 that returns a dict of the build count summary for the archive:
145
146- >>> print(ppa_archive_view.build_counters)
147- {'failed': 1L, 'superseded': 0, 'total': 4L, ...
148+ >>> for key, value in sorted(ppa_archive_view.build_counters.items()):
149+ ... print('%s: %d' % (key, value))
150+ failed: 1
151+ ...
152+ superseded: 0
153+ total: 4
154
155 An ArchiveView also includes an easy way to get any
156 IPackageCopyRequest's associated with an archive:
157@@ -381,8 +385,11 @@ We can optionally pass the number of days.
158 The ArchiveView includes a helper to return the number of packages that
159 are building as well as the number of packages waiting to build.
160
161- >>> print(view.num_pkgs_building)
162- {'building': 0, 'waiting': 0, 'total': 0}
163+ >>> for key, value in sorted(view.num_pkgs_building.items()):
164+ ... print('%s: %d' % (key, value))
165+ building: 0
166+ total: 0
167+ waiting: 0
168
169 Let's set some builds appropriately to see the results.
170
171@@ -410,22 +417,31 @@ Let's set some builds appropriately to see the results.
172 >>> builds[2].updateStatus(
173 ... BuildStatus.BUILDING, force_invalid_transition=True)
174
175- >>> view.num_pkgs_building
176- {'building': 2, 'waiting': 1, 'total': 3}
177+ >>> for key, value in sorted(view.num_pkgs_building.items()):
178+ ... print('%s: %d' % (key, value))
179+ building: 2
180+ total: 3
181+ waiting: 1
182
183 Adding a second waiting build for the cdrkit does not add to the number
184 of packages that are currently building.
185
186 >>> builds[4].updateStatus(BuildStatus.NEEDSBUILD)
187- >>> view.num_pkgs_building
188- {'building': 2, 'waiting': 1, 'total': 3}
189+ >>> for key, value in sorted(view.num_pkgs_building.items()):
190+ ... print('%s: %d' % (key, value))
191+ building: 2
192+ total: 3
193+ waiting: 1
194
195 But as soon as one of cdrkit's builds start, the package is considered
196 to be building:
197
198 >>> builds[4].updateStatus(BuildStatus.BUILDING)
199- >>> view.num_pkgs_building
200- {'building': 3, 'waiting': 0, 'total': 3}
201+ >>> for key, value in sorted(view.num_pkgs_building.items()):
202+ ... print('%s: %d' % (key, value))
203+ building: 3
204+ total: 3
205+ waiting: 0
206
207 The archive index view overrides the default series filter to use the
208 distroseries from the browser's user-agent, when applicable.
209diff --git a/lib/lp/soyuz/doc/publishing.txt b/lib/lp/soyuz/doc/publishing.txt
210index bacb573..365028c 100644
211--- a/lib/lp/soyuz/doc/publishing.txt
212+++ b/lib/lp/soyuz/doc/publishing.txt
213@@ -944,10 +944,14 @@ getDownloadCounts lets us filter by date.
214 We can also get a dict of totals for each day. The keys are strings to
215 work around lazr.restful's dict limitations. This too has a date filter.
216
217- >>> bpph.getDailyDownloadTotals()
218- {'2010-02-21': 14L, '2010-02-19': 2L}
219- >>> bpph.getDailyDownloadTotals(start_date=date(2010, 2, 20))
220- {'2010-02-21': 14L}
221+ >>> for day, total in sorted(bpph.getDailyDownloadTotals().items()):
222+ ... print('%s: %d' % (day, total))
223+ 2010-02-19: 2
224+ 2010-02-21: 14
225+ >>> for day, total in sorted(bpph.getDailyDownloadTotals(
226+ ... start_date=date(2010, 2, 20)).items()):
227+ ... print('%s: %d' % (day, total))
228+ 2010-02-21: 14
229
230
231 IPublishingSet
232diff --git a/lib/lp/testing/systemdocs.py b/lib/lp/testing/systemdocs.py
233index 8b0e87c..3d42c6f 100644
234--- a/lib/lp/testing/systemdocs.py
235+++ b/lib/lp/testing/systemdocs.py
236@@ -222,8 +222,9 @@ def stop():
237 class PrettyPrinter(pprint.PrettyPrinter, object):
238 """A pretty-printer that formats text in the Python 3 style.
239
240- This should only be used when the resulting ambiguity between str and
241- unicode representation on Python 2 is not a problem.
242+ This should only be used when the resulting ambiguities between str and
243+ unicode representation and between int and long representation on Python
244+ 2 are not a problem.
245 """
246
247 def format(self, obj, contexts, maxlevels, level):
248@@ -233,6 +234,8 @@ class PrettyPrinter(pprint.PrettyPrinter, object):
249 return '"%s"' % obj, True, False
250 else:
251 return "'%s'" % obj.replace("'", "\\'"), True, False
252+ elif sys.version_info[0] < 3 and isinstance(obj, long):
253+ return repr(int(obj)), True, False
254 else:
255 return super(PrettyPrinter, self).format(
256 obj, contexts, maxlevels, level)

Subscribers

People subscribed via source and target branches

to status/vote changes: