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
diff --git a/lib/lp/bugs/doc/bugsummary.txt b/lib/lp/bugs/doc/bugsummary.txt
index 77299eb..1709e10 100644
--- a/lib/lp/bugs/doc/bugsummary.txt
+++ b/lib/lp/bugs/doc/bugsummary.txt
@@ -370,15 +370,15 @@ a sourcepackage, so we subtract this count from the total number of bugs
370targeted to the distribution:370targeted to the distribution:
371371
372 >>> from storm.expr import SQL372 >>> from storm.expr import SQL
373 >>> store.find(373 >>> print(store.find(
374 ... BugSummary,374 ... BugSummary,
375 ... BugSummary.distribution == distribution,375 ... BugSummary.distribution == distribution,
376 ... BugSummary.status == BugTaskStatus.CONFIRMED,376 ... BugSummary.status == BugTaskStatus.CONFIRMED,
377 ... BugSummary.viewed_by == None,377 ... BugSummary.viewed_by == None,
378 ... BugSummary.tag == None).sum(SQL("""378 ... BugSummary.tag == None).sum(SQL("""
379 ... CASE WHEN sourcepackagename IS NULL THEN count ELSE -count END379 ... CASE WHEN sourcepackagename IS NULL THEN count ELSE -count END
380 ... """)) or 0380 ... """)) or 0)
381 1L381 1
382382
383383
384DistroSeries Bug Counts384DistroSeries Bug Counts
diff --git a/lib/lp/bugs/scripts/tests/test_bugsummaryrebuild.py b/lib/lp/bugs/scripts/tests/test_bugsummaryrebuild.py
index 7c246c1..b384550 100644
--- a/lib/lp/bugs/scripts/tests/test_bugsummaryrebuild.py
+++ b/lib/lp/bugs/scripts/tests/test_bugsummaryrebuild.py
@@ -3,6 +3,8 @@
33
4__metaclass__ = type4__metaclass__ = type
55
6import sys
7
6from testtools.content import text_content8from testtools.content import text_content
7from testtools.matchers import MatchesRegex9from testtools.matchers import MatchesRegex
8import transaction10import transaction
@@ -139,10 +141,12 @@ class TestBugSummaryRebuild(TestCaseWithFactory):
139 rebuild_bugsummary_for_target(product, log)141 rebuild_bugsummary_for_target(product, log)
140 self.assertEqual(1, get_bugsummary_rows(product).count())142 self.assertEqual(1, get_bugsummary_rows(product).count())
141 self.assertEqual(0, get_bugsummaryjournal_rows(product).count())143 self.assertEqual(0, get_bugsummaryjournal_rows(product).count())
144 long_type = int if sys.version_info[0] >= 3 else long
142 self.assertThat(145 self.assertThat(
143 log.getLogBufferAndClear(),146 log.getLogBufferAndClear(),
144 MatchesRegex(147 MatchesRegex(
145 'DEBUG Rebuilding %s\nDEBUG Added {.*: 1L}' % product.name))148 'DEBUG Rebuilding %s\nDEBUG Added {.*: %r}' %
149 (product.name, long_type(1))))
146150
147 def test_script(self):151 def test_script(self):
148 product = self.factory.makeProduct()152 product = self.factory.makeProduct()
diff --git a/lib/lp/buildmaster/doc/builder.txt b/lib/lp/buildmaster/doc/builder.txt
index 51c039d..e3620e9 100644
--- a/lib/lp/buildmaster/doc/builder.txt
+++ b/lib/lp/buildmaster/doc/builder.txt
@@ -98,8 +98,11 @@ virtualization status, architecture, then name.
98Processor/virtualization.98Processor/virtualization.
9999
100 >>> queue_sizes = builderset.getBuildQueueSizes()100 >>> queue_sizes = builderset.getBuildQueueSizes()
101 >>> queue_sizes['nonvirt']['386']101 >>> size, duration = queue_sizes['nonvirt']['386']
102 (1L, datetime.timedelta(0, 60))102 >>> print(size)
103 1
104 >>> print(duration)
105 0:01:00
103106
104There are no 'amd64' build queue entries.107There are no 'amd64' build queue entries.
105108
@@ -142,8 +145,11 @@ Let's re-enable the ubuntu primary archive.
142The build for the ubuntu primary archive shows up again.145The build for the ubuntu primary archive shows up again.
143146
144 >>> queue_sizes = builderset.getBuildQueueSizes()147 >>> queue_sizes = builderset.getBuildQueueSizes()
145 >>> queue_sizes['nonvirt']['386']148 >>> size, duration = queue_sizes['nonvirt']['386']
146 (1L, datetime.timedelta(0, 60))149 >>> print(size)
150 1
151 >>> print(duration)
152 0:01:00
147153
148All job types are included. If we create a recipe build job, it will154All job types are included. If we create a recipe build job, it will
149show up in the calculated queue size.155show up in the calculated queue size.
@@ -152,5 +158,8 @@ show up in the calculated queue size.
152 ... distroseries=ubuntu.currentseries).queueBuild()158 ... distroseries=ubuntu.currentseries).queueBuild()
153 >>> transaction.commit()159 >>> transaction.commit()
154 >>> queue_sizes = builderset.getBuildQueueSizes()160 >>> queue_sizes = builderset.getBuildQueueSizes()
155 >>> print(queue_sizes['virt']['386'])161 >>> size, duration = queue_sizes['virt']['386']
156 (1L, datetime.timedelta(0, 600))162 >>> print(size)
163 1
164 >>> print(duration)
165 0:10:00
diff --git a/lib/lp/registry/browser/tests/poll-views_0.txt b/lib/lp/registry/browser/tests/poll-views_0.txt
index 47ab535..2048cb1 100644
--- a/lib/lp/registry/browser/tests/poll-views_0.txt
+++ b/lib/lp/registry/browser/tests/poll-views_0.txt
@@ -65,12 +65,12 @@ matrix as a python list, with the necessary headers (the option's names).
6565
66 >>> poll_results = getMultiAdapter((poll, TestRequest()), name="+index")66 >>> poll_results = getMultiAdapter((poll, TestRequest()), name="+index")
67 >>> for row in poll_results.getPairwiseMatrixWithHeaders():67 >>> for row in poll_results.getPairwiseMatrixWithHeaders():
68 ... print(row)68 ... print(pretty(row))
69 [None, u'A', u'B', u'C', u'D']69 [None, 'A', 'B', 'C', 'D']
70 [u'A', None, 2L, 2L, 2L]70 ['A', None, 2, 2, 2]
71 [u'B', 2L, None, 2L, 2L]71 ['B', 2, None, 2, 2]
72 [u'C', 1L, 1L, None, 1L]72 ['C', 1, 1, None, 1]
73 [u'D', 2L, 1L, 2L, None]73 ['D', 2, 1, 2, None]
7474
75== Voting on closed polls ==75== Voting on closed polls ==
7676
diff --git a/lib/lp/registry/doc/poll.txt b/lib/lp/registry/doc/poll.txt
index 6ef79a1..b1ef334 100644
--- a/lib/lp/registry/doc/poll.txt
+++ b/lib/lp/registry/doc/poll.txt
@@ -131,10 +131,10 @@ people can start voting.
131 >>> votes = poll2.storeCondorcetVote(member3, options, when=opendate)131 >>> votes = poll2.storeCondorcetVote(member3, options, when=opendate)
132 >>> options = {a: 1}132 >>> options = {a: 1}
133 >>> votes = poll2.storeCondorcetVote(member4, options, when=opendate)133 >>> votes = poll2.storeCondorcetVote(member4, options, when=opendate)
134 >>> from zope.security.proxy import removeSecurityProxy
134 >>> for row in poll2.getPairwiseMatrix():135 >>> for row in poll2.getPairwiseMatrix():
135 ... print row136 ... print(pretty(removeSecurityProxy(row)))
136 [None, 2L, 2L, 2L]137 [None, 2, 2, 2]
137 [2L, None, 2L, 2L]138 [2, None, 2, 2]
138 [1L, 1L, None, 1L]139 [1, 1, None, 1]
139 [2L, 1L, 2L, None]140 [2, 1, 2, None]
140
diff --git a/lib/lp/soyuz/browser/tests/archive-views.txt b/lib/lp/soyuz/browser/tests/archive-views.txt
index e27c6d6..ed0598a 100644
--- a/lib/lp/soyuz/browser/tests/archive-views.txt
+++ b/lib/lp/soyuz/browser/tests/archive-views.txt
@@ -60,8 +60,12 @@ The ArchiveView provides the html for the inline description editing widget.
60For convenience the ArchiveView also includes a build_counters property60For convenience the ArchiveView also includes a build_counters property
61that returns a dict of the build count summary for the archive:61that returns a dict of the build count summary for the archive:
6262
63 >>> print(ppa_archive_view.build_counters)63 >>> for key, value in sorted(ppa_archive_view.build_counters.items()):
64 {'failed': 1L, 'superseded': 0, 'total': 4L, ...64 ... print('%s: %d' % (key, value))
65 failed: 1
66 ...
67 superseded: 0
68 total: 4
6569
66An ArchiveView also includes an easy way to get any70An ArchiveView also includes an easy way to get any
67IPackageCopyRequest's associated with an archive:71IPackageCopyRequest's associated with an archive:
@@ -381,8 +385,11 @@ We can optionally pass the number of days.
381The ArchiveView includes a helper to return the number of packages that385The ArchiveView includes a helper to return the number of packages that
382are building as well as the number of packages waiting to build.386are building as well as the number of packages waiting to build.
383387
384 >>> print(view.num_pkgs_building)388 >>> for key, value in sorted(view.num_pkgs_building.items()):
385 {'building': 0, 'waiting': 0, 'total': 0}389 ... print('%s: %d' % (key, value))
390 building: 0
391 total: 0
392 waiting: 0
386393
387Let's set some builds appropriately to see the results.394Let's set some builds appropriately to see the results.
388395
@@ -410,22 +417,31 @@ Let's set some builds appropriately to see the results.
410 >>> builds[2].updateStatus(417 >>> builds[2].updateStatus(
411 ... BuildStatus.BUILDING, force_invalid_transition=True)418 ... BuildStatus.BUILDING, force_invalid_transition=True)
412419
413 >>> view.num_pkgs_building420 >>> for key, value in sorted(view.num_pkgs_building.items()):
414 {'building': 2, 'waiting': 1, 'total': 3}421 ... print('%s: %d' % (key, value))
422 building: 2
423 total: 3
424 waiting: 1
415425
416Adding a second waiting build for the cdrkit does not add to the number426Adding a second waiting build for the cdrkit does not add to the number
417of packages that are currently building.427of packages that are currently building.
418428
419 >>> builds[4].updateStatus(BuildStatus.NEEDSBUILD)429 >>> builds[4].updateStatus(BuildStatus.NEEDSBUILD)
420 >>> view.num_pkgs_building430 >>> for key, value in sorted(view.num_pkgs_building.items()):
421 {'building': 2, 'waiting': 1, 'total': 3}431 ... print('%s: %d' % (key, value))
432 building: 2
433 total: 3
434 waiting: 1
422435
423But as soon as one of cdrkit's builds start, the package is considered436But as soon as one of cdrkit's builds start, the package is considered
424to be building:437to be building:
425438
426 >>> builds[4].updateStatus(BuildStatus.BUILDING)439 >>> builds[4].updateStatus(BuildStatus.BUILDING)
427 >>> view.num_pkgs_building440 >>> for key, value in sorted(view.num_pkgs_building.items()):
428 {'building': 3, 'waiting': 0, 'total': 3}441 ... print('%s: %d' % (key, value))
442 building: 3
443 total: 3
444 waiting: 0
429445
430The archive index view overrides the default series filter to use the446The archive index view overrides the default series filter to use the
431distroseries from the browser's user-agent, when applicable.447distroseries from the browser's user-agent, when applicable.
diff --git a/lib/lp/soyuz/doc/publishing.txt b/lib/lp/soyuz/doc/publishing.txt
index bacb573..365028c 100644
--- a/lib/lp/soyuz/doc/publishing.txt
+++ b/lib/lp/soyuz/doc/publishing.txt
@@ -944,10 +944,14 @@ getDownloadCounts lets us filter by date.
944We can also get a dict of totals for each day. The keys are strings to944We can also get a dict of totals for each day. The keys are strings to
945work around lazr.restful's dict limitations. This too has a date filter.945work around lazr.restful's dict limitations. This too has a date filter.
946946
947 >>> bpph.getDailyDownloadTotals()947 >>> for day, total in sorted(bpph.getDailyDownloadTotals().items()):
948 {'2010-02-21': 14L, '2010-02-19': 2L}948 ... print('%s: %d' % (day, total))
949 >>> bpph.getDailyDownloadTotals(start_date=date(2010, 2, 20))949 2010-02-19: 2
950 {'2010-02-21': 14L}950 2010-02-21: 14
951 >>> for day, total in sorted(bpph.getDailyDownloadTotals(
952 ... start_date=date(2010, 2, 20)).items()):
953 ... print('%s: %d' % (day, total))
954 2010-02-21: 14
951955
952956
953IPublishingSet957IPublishingSet
diff --git a/lib/lp/testing/systemdocs.py b/lib/lp/testing/systemdocs.py
index 8b0e87c..3d42c6f 100644
--- a/lib/lp/testing/systemdocs.py
+++ b/lib/lp/testing/systemdocs.py
@@ -222,8 +222,9 @@ def stop():
222class PrettyPrinter(pprint.PrettyPrinter, object):222class PrettyPrinter(pprint.PrettyPrinter, object):
223 """A pretty-printer that formats text in the Python 3 style.223 """A pretty-printer that formats text in the Python 3 style.
224224
225 This should only be used when the resulting ambiguity between str and225 This should only be used when the resulting ambiguities between str and
226 unicode representation on Python 2 is not a problem.226 unicode representation and between int and long representation on Python
227 2 are not a problem.
227 """228 """
228229
229 def format(self, obj, contexts, maxlevels, level):230 def format(self, obj, contexts, maxlevels, level):
@@ -233,6 +234,8 @@ class PrettyPrinter(pprint.PrettyPrinter, object):
233 return '"%s"' % obj, True, False234 return '"%s"' % obj, True, False
234 else:235 else:
235 return "'%s'" % obj.replace("'", "\\'"), True, False236 return "'%s'" % obj.replace("'", "\\'"), True, False
237 elif sys.version_info[0] < 3 and isinstance(obj, long):
238 return repr(int(obj)), True, False
236 else:239 else:
237 return super(PrettyPrinter, self).format(240 return super(PrettyPrinter, self).format(
238 obj, contexts, maxlevels, level)241 obj, contexts, maxlevels, level)

Subscribers

People subscribed via source and target branches

to status/vote changes: