Merge lp:~cjwatson/storm/py3-doctest into lp:storm

Proposed by Colin Watson
Status: Merged
Merged at revision: 513
Proposed branch: lp:~cjwatson/storm/py3-doctest
Merge into: lp:storm
Diff against target: 400 lines (+120/-67)
3 files modified
tests/infoheritance.txt (+12/-6)
tests/tutorial.txt (+101/-57)
tests/zope/README.txt (+7/-4)
To merge this branch: bzr merge lp:~cjwatson/storm/py3-doctest
Reviewer Review Type Date Requested Status
Kristian Glass (community) Approve
Storm Developers Pending
Review via email: mp+371161@code.launchpad.net

Commit message

Adjust doctests for text repr changes in Python 3.

Description of the change

None of these doctests need to care about the fine details of str vs. Unicode in Python 2 (that sort of thing is tested more specifically in unit tests), and in Python 3 the repr of a text string is '...' rather than u'...'. Rearrange the doctests to tolerate this.

To post a comment you must log in.
Revision history for this message
Kristian Glass (doismellburning) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/infoheritance.txt'
2--- tests/infoheritance.txt 2009-02-04 02:00:02 +0000
3+++ tests/infoheritance.txt 2019-08-11 10:01:42 +0000
4@@ -224,12 +224,16 @@
5 ... return result
6
7 >>> secret_agent = get_persons(store, info_classes=[SecretAgent]).one()
8->>> secret_agent.name, secret_agent.info.passcode
9-(u'Dick Tracy', u'secret!')
10+>>> print(secret_agent.name)
11+Dick Tracy
12+>>> print(secret_agent.info.passcode)
13+secret!
14
15 >>> teacher = get_persons(store, info_classes=[Teacher]).one()
16->>> teacher.name, teacher.info.school
17-(u'Mrs. Cohen', u'Cameron Elementary School')
18+>>> print(teacher.name)
19+Mrs. Cohen
20+>>> print(teacher.info.school)
21+Cameron Elementary School
22
23 >>>
24 }}}
25@@ -260,8 +264,10 @@
26 >>> store.rollback()
27
28 >>> ghost = get_persons(store, info_classes=[Ghost]).one()
29->>> ghost.name, ghost.info.friendly
30-(u'Casper', True)
31+>>> print(ghost.name)
32+Casper
33+>>> print(ghost.info.friendly)
34+True
35
36 >>>
37 }}}
38
39=== modified file 'tests/tutorial.txt'
40--- tests/tutorial.txt 2019-06-05 11:41:07 +0000
41+++ tests/tutorial.txt 2019-08-11 10:01:42 +0000
42@@ -73,8 +73,10 @@
43 >>> joe = Person()
44 >>> joe.name = u"Joe Johnes"
45
46->>> print("%r, %r" % (joe.id, joe.name))
47-None, u'Joe Johnes'
48+>>> print(joe.id)
49+None
50+>>> print(joe.name)
51+Joe Johnes
52
53 }}}
54
55@@ -85,8 +87,10 @@
56 >>> store.add(joe)
57 <...Person object at 0x...>
58
59->>> print("%r, %r" % (joe.id, joe.name))
60-None, u'Joe Johnes'
61+>>> print(joe.id)
62+None
63+>>> print(joe.name)
64+Joe Johnes
65
66 }}}
67
68@@ -116,8 +120,10 @@
69 {{{#!python
70 >>> person = store.find(Person, Person.name == u"Joe Johnes").one()
71
72->>> print("%r, %r" % (person.id, person.name))
73-1, u'Joe Johnes'
74+>>> print(person.id)
75+1
76+>>> print(person.name)
77+Joe Johnes
78
79 >>>
80 }}}
81@@ -127,8 +133,8 @@
82 We can also retrieve the object using its primary key.
83
84 {{{#!python
85->>> store.get(Person, 1).name
86-u'Joe Johnes'
87+>>> print(store.get(Person, 1).name)
88+Joe Johnes
89
90 }}}
91
92@@ -168,12 +174,16 @@
93 >>> store.add(mary)
94 <...Person object at 0x...>
95
96->>> print("%r, %r" % (mary.id, mary.name))
97-None, u'Mary Margaret'
98+>>> print(mary.id)
99+None
100+>>> print(mary.name)
101+Mary Margaret
102
103 >>> store.flush()
104->>> print("%r, %r" % (mary.id, mary.name))
105-2, u'Mary Margaret'
106+>>> print(mary.id)
107+2
108+>>> print(mary.name)
109+Mary Margaret
110
111 }}}
112
113@@ -184,8 +194,8 @@
114
115 {{{#!python
116 >>> store.find(Person, Person.name == u"Mary Margaret").set(name=u"Mary Maggie")
117->>> mary.name
118-u'Mary Maggie'
119+>>> print(mary.name)
120+Mary Maggie
121
122 }}}
123
124@@ -240,8 +250,10 @@
125 Actually, something happened.. with Joe. He's back!
126
127 {{{#!python
128->>> print("%r, %r" % (joe.id, joe.name))
129-1, u'Joe Johnes'
130+>>> print(joe.id)
131+1
132+>>> print(joe.name)
133+Joe Johnes
134
135 }}}
136
137@@ -279,8 +291,10 @@
138 {{{
139 >>> circus = Company(u"Circus Inc.")
140
141->>> print("%r, %r" % (circus.id, circus.name))
142-None, u'Circus Inc.'
143+>>> print(circus.id)
144+None
145+>>> print(circus.name)
146+Circus Inc.
147
148 }}}
149
150@@ -327,8 +341,12 @@
151 {{{#!python
152 >>> ben = store.add(Employee(u"Ben Bill"))
153
154->>> print("%r, %r, %r" % (ben.id, ben.name, ben.company_id))
155-None, u'Ben Bill', None
156+>>> print(ben.id)
157+None
158+>>> print(ben.name)
159+Ben Bill
160+>>> print(ben.company_id)
161+None
162
163 }}}
164
165@@ -338,8 +356,10 @@
166 {{{#!python
167 >>> ben.company = circus
168
169->>> print("%r, %r" % (ben.company_id, ben.company.name))
170-None, u'Circus Inc.'
171+>>> print(ben.company_id)
172+None
173+>>> print(ben.company.name)
174+Circus Inc.
175
176 }}}
177
178@@ -354,8 +374,10 @@
179 {{{#!python
180 >>> store.flush()
181
182->>> print("%r, %r" % (ben.company_id, ben.company.name))
183-1, u'Circus Inc.'
184+>>> print(ben.company_id)
185+1
186+>>> print(ben.company.name)
187+Circus Inc.
188
189 }}}
190
191@@ -381,8 +403,8 @@
192
193 {{{#!python
194 >>> ben.company_id = 2
195->>> ben.company.name
196-u'Sweets Inc.'
197+>>> print(ben.company.name)
198+Sweets Inc.
199 >>> ben.company is sweets
200 True
201
202@@ -419,10 +441,12 @@
203 1
204
205 >>> for employee in sweets.employees:
206-... print("%r, %r" % (employee.id, employee.name))
207+... print(employee.id)
208+... print(employee.name)
209 ... print(employee is ben)
210 ...
211-1, u'Ben Bill'
212+1
213+Ben Bill
214 True
215
216 }}}
217@@ -555,11 +579,14 @@
218 ... CompanyAccountant.company_id,
219 ... Company.id)
220
221->>> sorted([company.name for company in frank.companies])
222-[u'Circus Inc.', u'Sweets Inc.']
223+>>> for name in sorted(company.name for company in frank.companies):
224+... print(name)
225+Circus Inc.
226+Sweets Inc.
227
228->>> [company.name for company in karl.companies]
229-[u'Sweets Inc.']
230+>>> for company in karl.companies:
231+... print(company.name)
232+Sweets Inc.
233
234 }}}
235
236@@ -580,8 +607,9 @@
237 ... Employee.name.like(u"Ben %"))
238 ...
239
240->>> [company.name for company in result]
241-[u'Sweets Inc.']
242+>>> for company in result:
243+... print(company.name)
244+Sweets Inc.
245
246 }}}
247
248@@ -592,8 +620,9 @@
249 >>> origin = [Company, Join(Employee, Employee.company_id == Company.id)]
250 >>> result = store.using(*origin).find(Company, Employee.name.like(u"Ben %"))
251
252->>> [company.name for company in result]
253-[u'Sweets Inc.']
254+>>> for company in result:
255+... print(company.name)
256+Sweets Inc.
257
258 }}}
259
260@@ -604,8 +633,9 @@
261 {{{#!python
262 >>> result = sweets.employees.find(Employee.name.like(u"Ben %"))
263
264->>> [employee.name for employee in result]
265-[u'Ben Bill']
266+>>> for employee in result:
267+... print(employee.name)
268+Ben Bill
269
270 }}}
271
272@@ -642,14 +672,22 @@
273
274 >>> result = store.find(Employee)
275
276->>> [employee.name for employee in result.order_by(Employee.name)]
277-[u'Ben Bill', u'Garry Glare', u'Mike Mayer']
278-
279->>> [employee.name for employee in result.order_by(Desc(Employee.name))]
280-[u'Mike Mayer', u'Garry Glare', u'Ben Bill']
281-
282->>> [employee.name for employee in result.order_by(Employee.name)[:2]]
283-[u'Ben Bill', u'Garry Glare']
284+>>> for employee in result.order_by(Employee.name):
285+... print(employee.name)
286+Ben Bill
287+Garry Glare
288+Mike Mayer
289+
290+>>> for employee in result.order_by(Desc(Employee.name)):
291+... print(employee.name)
292+Mike Mayer
293+Garry Glare
294+Ben Bill
295+
296+>>> for employee in result.order_by(Employee.name)[:2]:
297+... print(employee.name)
298+Ben Bill
299+Garry Glare
300
301 }}}
302
303@@ -666,8 +704,11 @@
304 ... Employee.company_id == Company.id,
305 ... Employee.name.like(u"Ben %"))
306
307->>> [(company.name, employee.name) for company, employee in result]
308-[(u'Sweets Inc.', u'Ben Bill')]
309+>>> for company, employee in result:
310+... print(company.name)
311+... print(employee.name)
312+Sweets Inc.
313+Ben Bill
314
315 }}}
316
317@@ -722,8 +763,8 @@
318 >>> brazil.name = u"Brazil"
319 >>> brazil.currency_id = 1
320
321->>> brazil.currency.symbol
322-u'BRL'
323+>>> print(brazil.currency.symbol)
324+BRL
325
326 }}}
327
328@@ -781,8 +822,9 @@
329
330 {{{#!python
331 >>> result = store.execute(Select(Person.name, Person.id == 1))
332->>> result.get_one()
333-(u'Joe Johnes',)
334+>>> (name,) = result.get_one()
335+>>> print(name)
336+Joe Johnes
337
338 }}}
339
340@@ -829,8 +871,8 @@
341 from storm.locals import SQL
342
343 >>> ruy.name = SQL("(SELECT name || ? FROM person WHERE id=4)", (" Ritcher",))
344->>> ruy.name
345-u'Ruy Ritcher'
346+>>> print(ruy.name)
347+Ruy Ritcher
348
349 }}}
350
351@@ -865,8 +907,10 @@
352 ... Employee.id > AnotherEmployee.id)
353
354 >>> for employee1, employee2 in result:
355-... print((employee1.name, employee2.name))
356-(u'Mike Mayer', u'Ben Bill')
357+... print(employee1.name)
358+... print(employee2.name)
359+Mike Mayer
360+Ben Bill
361
362 }}}
363
364@@ -895,7 +939,7 @@
365 ... Employee.company_id == AnotherEmployee.company_id,
366 ... Employee.id > AnotherEmployee.id)
367 >>> list(result)
368-[...] EXECUTE: u'SELECT employee.company_id, employee.id, employee.name, "...".company_id, "...".id, "...".name FROM employee, employee AS "..." WHERE employee.company_id = "...".company_id AND employee.id > "...".id', ()
369+[...] EXECUTE: ...'SELECT employee.company_id, employee.id, employee.name, "...".company_id, "...".id, "...".name FROM employee, employee AS "..." WHERE employee.company_id = "...".company_id AND employee.id > "...".id', ()
370 [...] DONE
371 [(<...Employee object at ...>, <...Employee object at ...>)]
372
373
374=== modified file 'tests/zope/README.txt'
375--- tests/zope/README.txt 2011-10-28 16:15:01 +0000
376+++ tests/zope/README.txt 2019-08-11 10:01:42 +0000
377@@ -139,16 +139,19 @@
378
379 At this point a store.find should return the new object.
380
381- >>> sorted([person.name for person in store.find(Person)])
382- [u'Imposter!', u'John Doe']
383+ >>> for name in sorted(person.name for person in store.find(Person)):
384+ ... print(name)
385+ Imposter!
386+ John Doe
387
388 All this means is that the data has been flushed to the database; it's
389 still not committed. If we abort the transaction the new Person
390 object should disappear.
391
392 >>> transaction.abort()
393- >>> [person.name for person in store.find(Person)]
394- [u'John Doe']
395+ >>> for person in store.find(Person):
396+ ... print(person.name)
397+ John Doe
398
399 Excellent! As you can see, ZStorm makes working with SQL databases
400 and Zope 3 very natural.

Subscribers

People subscribed via source and target branches

to status/vote changes: