Merge lp:~cjwatson/launchpad/range-iterator into lp:launchpad

Proposed by Colin Watson
Status: Merged
Merged at revision: 18546
Proposed branch: lp:~cjwatson/launchpad/range-iterator
Merge into: lp:launchpad
Diff against target: 303 lines (+39/-38)
11 files modified
lib/lp/app/browser/tests/launchpad-search-pages.txt (+2/-2)
lib/lp/registry/scripts/tests/test_populate_distroseriesdiff.py (+4/-4)
lib/lp/services/database/doc/decoratedresultset.txt (+1/-1)
lib/lp/services/database/doc/multitablecopy.txt (+1/-1)
lib/lp/services/feeds/tests/helper.py (+3/-3)
lib/lp/services/webapp/tests/test_batching.py (+16/-15)
lib/lp/soyuz/tests/test_distroseriesdifferencejob.py (+2/-2)
lib/lp/translations/browser/tests/test_translationmessage_view.py (+2/-2)
lib/lp/translations/browser/translationmessage.py (+2/-2)
lib/lp/translations/model/potmsgset.py (+3/-3)
lib/lp/translations/utilities/pluralforms.py (+3/-3)
To merge this branch: bzr merge lp:~cjwatson/launchpad/range-iterator
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+337043@code.launchpad.net

Commit message

Prepare for range returning an iterator in Python 3.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/app/browser/tests/launchpad-search-pages.txt'
2--- lib/lp/app/browser/tests/launchpad-search-pages.txt 2016-01-26 15:47:37 +0000
3+++ lib/lp/app/browser/tests/launchpad-search-pages.txt 2018-02-02 10:37:18 +0000
4@@ -683,7 +683,7 @@
5 Even if the PageMatch object to have an impossibly large size, the
6 navigator conforms to Google's maximum size of 20.
7
8- >>> matches = range(0, 100)
9+ >>> matches = list(range(0, 100))
10 >>> page_matches._matches = matches
11 >>> page_matches.start = 0
12 >>> page_matches.total = 100
13@@ -703,7 +703,7 @@
14 the PageMatches object, so only 3 are yielded. The start of the next
15 batch is 20, which is the start of the next batch from Google.
16
17- >>> matches = range(0, 3)
18+ >>> matches = list(range(0, 3))
19 >>> page_matches._matches = matches
20 >>> navigator = GoogleBatchNavigator(
21 ... page_matches, search_view.request, page_matches.start, size=100)
22
23=== modified file 'lib/lp/registry/scripts/tests/test_populate_distroseriesdiff.py'
24--- lib/lp/registry/scripts/tests/test_populate_distroseriesdiff.py 2012-01-17 21:45:24 +0000
25+++ lib/lp/registry/scripts/tests/test_populate_distroseriesdiff.py 2018-02-02 10:37:18 +0000
26@@ -1,4 +1,4 @@
27-# Copyright 2011 Canonical Ltd. This software is licensed under the
28+# Copyright 2011-2018 Canonical Ltd. This software is licensed under the
29 # GNU Affero General Public License version 3 (see the file LICENSE).
30
31 """Test the populate-distroseriesdiff script."""
32@@ -521,15 +521,15 @@
33 self.assertFalse(self.makeFixer([1]).isDone())
34
35 def test_cutChunk_one_cuts_exactly_one(self):
36- fixer = self.makeFixer(range(3))
37+ fixer = self.makeFixer(list(range(3)))
38 chunk = fixer._cutChunk(1)
39 self.assertEqual([0], chunk)
40 self.assertEqual(3 - 1, len(fixer.ids))
41
42 def test_cutChunk_over_remaining_size_completes_loop(self):
43- fixer = self.makeFixer(range(3))
44+ fixer = self.makeFixer(list(range(3)))
45 chunk = fixer._cutChunk(100)
46- self.assertContentEqual(range(3), chunk)
47+ self.assertContentEqual(list(range(3)), chunk)
48 self.assertEqual([], fixer.ids)
49
50 def test_updatesBaseVersion(self):
51
52=== modified file 'lib/lp/services/database/doc/decoratedresultset.txt'
53--- lib/lp/services/database/doc/decoratedresultset.txt 2014-01-13 11:42:59 +0000
54+++ lib/lp/services/database/doc/decoratedresultset.txt 2018-02-02 10:37:18 +0000
55@@ -163,7 +163,7 @@
56 ... pass
57 ... def copy(self, *args, **kwargs):
58 ... return FakeResultSet(self)
59- >>> rs = FakeResultSet(range(1,5))
60+ >>> rs = FakeResultSet(list(range(1, 5)))
61 >>> def my_pih(result_set):
62 ... print('this should run once only, count: %s' % len(result_set))
63 >>> def my_deco(result):
64
65=== modified file 'lib/lp/services/database/doc/multitablecopy.txt'
66--- lib/lp/services/database/doc/multitablecopy.txt 2011-12-30 06:47:17 +0000
67+++ lib/lp/services/database/doc/multitablecopy.txt 2018-02-02 10:37:18 +0000
68@@ -25,7 +25,7 @@
69 >>> tables_to_clean_up.append('textual')
70 >>> cur.execute(
71 ... "CREATE TABLE textual (id SERIAL PRIMARY KEY, t varchar)")
72- >>> numeric_values = range(1,4)
73+ >>> numeric_values = list(range(1, 4))
74 >>> textual_values = ['one', 'two', 'three']
75 >>> for number in numeric_values:
76 ... cur.execute("INSERT INTO numeric (n) VALUES (%d)" % number)
77
78=== modified file 'lib/lp/services/feeds/tests/helper.py'
79--- lib/lp/services/feeds/tests/helper.py 2015-10-14 15:22:01 +0000
80+++ lib/lp/services/feeds/tests/helper.py 2018-02-02 10:37:18 +0000
81@@ -1,4 +1,4 @@
82-# Copyright 2009 Canonical Ltd. This software is licensed under the
83+# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
84 # GNU Affero General Public License version 3 (see the file LICENSE).
85
86 """Helper functions for testing feeds."""
87@@ -121,9 +121,9 @@
88 # which column contains the error.
89 max_line_length = 66
90 wrapped_column_number = column_number % max_line_length
91- line_number_range = range(
92+ line_number_range = list(range(
93 max(error_line_number - 2, 1),
94- min(error_line_number + 3, len(lines)))
95+ min(error_line_number + 3, len(lines))))
96 for line_number in line_number_range:
97 unicode_line = unicode(
98 lines[line_number - 1], 'ascii', 'replace')
99
100=== modified file 'lib/lp/services/webapp/tests/test_batching.py'
101--- lib/lp/services/webapp/tests/test_batching.py 2018-01-02 16:10:26 +0000
102+++ lib/lp/services/webapp/tests/test_batching.py 2018-02-02 10:37:18 +0000
103@@ -1,4 +1,4 @@
104-# Copyright 2011-2016 Canonical Ltd. This software is licensed under the
105+# Copyright 2011-2018 Canonical Ltd. This software is licensed under the
106 # GNU Affero General Public License version 3 (see the file LICENSE).
107
108 __metaclass__ = type
109@@ -635,7 +635,7 @@
110
111 def test_ShadowedList__init(self):
112 # ShadowedList instances need two lists as constructor parametrs.
113- list1 = range(3)
114+ list1 = list(range(3))
115 list2 = self.makeStringSequence(list1)
116 shadowed_list = ShadowedList(list1, list2)
117 self.assertEqual(shadowed_list.values, list1)
118@@ -643,24 +643,25 @@
119
120 def test_ShadowedList__init__non_sequence_parameter(self):
121 # values and shadow_values must be sequences.
122- self.assertRaises(TypeError, ShadowedList, 1, range(3))
123- self.assertRaises(TypeError, ShadowedList, range(3), 1)
124+ self.assertRaises(TypeError, ShadowedList, 1, list(range(3)))
125+ self.assertRaises(TypeError, ShadowedList, list(range(3)), 1)
126
127 def test_ShadowedList__init__different_list_lengths(self):
128 # values and shadow_values must have the same length.
129- self.assertRaises(ValueError, ShadowedList, range(2), range(3))
130+ self.assertRaises(
131+ ValueError, ShadowedList, list(range(2)), list(range(3)))
132
133 def test_ShadowedList__len(self):
134 # The length of a ShadowedList ist the same as the list of
135 # the sequences it stores.
136- list1 = range(3)
137+ list1 = list(range(3))
138 list2 = self.makeStringSequence(list1)
139 self.assertEqual(len(list1), len(ShadowedList(list1, list2)))
140
141 def test_ShadowedList__slice(self):
142 # A slice of a ShadowedList contains the slices of its
143 # values and shaow_values.
144- list1 = range(5)
145+ list1 = list(range(5))
146 list2 = self.makeStringSequence(list1)
147 shadowed_list = ShadowedList(list1, list2)
148 self.assertEqual(list1[2:4], shadowed_list[2:4].values)
149@@ -668,18 +669,18 @@
150
151 def test_ShadowedList__getitem(self):
152 # Accessing a single element of a ShadowedList is equivalent to
153- # accessig an element of its values attribute.
154- list1 = range(3)
155+ # accessing an element of its values attribute.
156+ list1 = list(range(3))
157 list2 = self.makeStringSequence(list1)
158 shadowed_list = ShadowedList(list1, list2)
159 self.assertEqual(list1[1], shadowed_list[1])
160
161 def test_ShadowedList__add(self):
162- # Two shadowedLists can be added, yielding another ShadowedList.
163- list1 = range(3)
164+ # Two ShadowedLists can be added, yielding another ShadowedList.
165+ list1 = list(range(3))
166 list2 = self.makeStringSequence(list1)
167 shadow_list1 = ShadowedList(list1, list2)
168- list3 = range(4)
169+ list3 = list(range(4))
170 list4 = self.makeStringSequence(list3)
171 shadow_list2 = ShadowedList(list3, list4)
172 list_sum = shadow_list1 + shadow_list2
173@@ -689,14 +690,14 @@
174
175 def test_ShadowedList__iterator(self):
176 # Iterating over a ShadowedList yields if values elements.
177- list1 = range(3)
178+ list1 = list(range(3))
179 list2 = self.makeStringSequence(list1)
180 shadow_list = ShadowedList(list1, list2)
181 self.assertEqual(list1, list(iter(shadow_list)))
182
183 def test_ShadowedList__reverse(self):
184 # ShadowList.reverse() reverses its elements.
185- list1 = range(3)
186+ list1 = list(range(3))
187 list2 = self.makeStringSequence(list1)
188 first1 = list1[0]
189 last1 = list1[-1]
190@@ -712,7 +713,7 @@
191 def test_ShadowedList__reverse__values_and_shadow_values_identical(self):
192 # ShadowList.reverse() works also when passed the same
193 # sequence as values and as shadow_values.
194- list_ = range(3)
195+ list_ = list(range(3))
196 shadow_list = ShadowedList(list_, list_)
197 shadow_list.reverse()
198 self.assertEqual(0, shadow_list[-1])
199
200=== modified file 'lib/lp/soyuz/tests/test_distroseriesdifferencejob.py'
201--- lib/lp/soyuz/tests/test_distroseriesdifferencejob.py 2018-01-02 16:10:26 +0000
202+++ lib/lp/soyuz/tests/test_distroseriesdifferencejob.py 2018-02-02 10:37:18 +0000
203@@ -1,4 +1,4 @@
204-# Copyright 2011-2013 Canonical Ltd. This software is licensed under the
205+# Copyright 2011-2018 Canonical Ltd. This software is licensed under the
206 # GNU Affero General Public License version 3 (see the file LICENSE).
207
208 """Test `DistroSeriesDifferenceJob` and utility."""
209@@ -407,7 +407,7 @@
210 dsp.parent_series, pocket=PackagePublishingPocket.RELEASE)
211 spn = spph.sourcepackagerelease.sourcepackagename
212
213- create_jobs = range(1, 3)
214+ create_jobs = list(range(1, 3))
215 for counter in create_jobs:
216 self.getJobSource().createForSPPHs([spph])
217
218
219=== modified file 'lib/lp/translations/browser/tests/test_translationmessage_view.py'
220--- lib/lp/translations/browser/tests/test_translationmessage_view.py 2016-02-05 16:51:12 +0000
221+++ lib/lp/translations/browser/tests/test_translationmessage_view.py 2018-02-02 10:37:18 +0000
222@@ -1,4 +1,4 @@
223-# Copyright 2009-2016 Canonical Ltd. This software is licensed under the
224+# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
225 # GNU Affero General Public License version 3 (see the file LICENSE).
226
227 from __future__ import with_statement
228@@ -416,7 +416,7 @@
229 revert_unselected_translations(translations, None, [0]))
230
231 def test_revert_unselected_translations_handles_plurals(self):
232- translated_forms = range(3)
233+ translated_forms = list(range(3))
234 translations = dict(
235 (form, self.getUniqueString()) for form in translated_forms)
236
237
238=== modified file 'lib/lp/translations/browser/translationmessage.py'
239--- lib/lp/translations/browser/translationmessage.py 2015-07-08 16:05:11 +0000
240+++ lib/lp/translations/browser/translationmessage.py 2018-02-02 10:37:18 +0000
241@@ -1,4 +1,4 @@
242-# Copyright 2009-2012 Canonical Ltd. This software is licensed under the
243+# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
244 # GNU Affero General Public License version 3 (see the file LICENSE).
245
246 """View classes for ITranslationMessage interface."""
247@@ -1067,7 +1067,7 @@
248 # suggestion_blocks dictionary, keyed on plural form index; this
249 # allows us later to just iterate over them in the view code
250 # using a generic template.
251- self.pluralform_indices = range(self.context.plural_forms)
252+ self.pluralform_indices = list(range(self.context.plural_forms))
253
254 self._buildAllSuggestions()
255
256
257=== modified file 'lib/lp/translations/model/potmsgset.py'
258--- lib/lp/translations/model/potmsgset.py 2015-07-08 16:05:11 +0000
259+++ lib/lp/translations/model/potmsgset.py 2018-02-02 10:37:18 +0000
260@@ -1,4 +1,4 @@
261-# Copyright 2009-2011 Canonical Ltd. This software is licensed under the
262+# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
263 # GNU Affero General Public License version 3 (see the file LICENSE).
264
265 __metaclass__ = type
266@@ -567,8 +567,8 @@
267 clauses.append('msgstr%s=%s' % (
268 sqlvalues(pluralform, potranslations[pluralform])))
269
270- remaining_plural_forms = range(
271- pofile.plural_forms, TranslationConstants.MAX_PLURAL_FORMS)
272+ remaining_plural_forms = list(range(
273+ pofile.plural_forms, TranslationConstants.MAX_PLURAL_FORMS))
274
275 # Prefer either shared or diverged messages, depending on
276 # arguments.
277
278=== modified file 'lib/lp/translations/utilities/pluralforms.py'
279--- lib/lp/translations/utilities/pluralforms.py 2015-10-14 16:23:18 +0000
280+++ lib/lp/translations/utilities/pluralforms.py 2018-02-02 10:37:18 +0000
281@@ -1,4 +1,4 @@
282-# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
283+# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
284 # GNU Affero General Public License version 3 (see the file LICENSE).
285
286 __metaclass__ = type
287@@ -40,7 +40,7 @@
288 forms[form].append(number)
289
290 found_forms = sorted(forms.keys())
291- if found_forms != range(expected_forms):
292+ if found_forms != list(range(expected_forms)):
293 raise BadPluralExpression(
294 "Plural expression should produce forms 0..%d, "
295 "but we found forms %s." % (expected_forms, found_forms))
296@@ -108,7 +108,7 @@
297 return identity_map
298
299 # Is either result out of range?
300- valid_forms = range(TranslationConstants.MAX_PLURAL_FORMS)
301+ valid_forms = list(range(TranslationConstants.MAX_PLURAL_FORMS))
302 if first_form not in valid_forms or second_form not in valid_forms:
303 return identity_map
304