Merge lp:~cjwatson/lazr.restful/py3-normalize-doctests into lp:lazr.restful
- py3-normalize-doctests
- Merge into trunk
Proposed by
Colin Watson
Status: | Merged |
---|---|
Merged at revision: | 258 |
Proposed branch: | lp:~cjwatson/lazr.restful/py3-normalize-doctests |
Merge into: | lp:lazr.restful |
Diff against target: |
528 lines (+90/-43) 13 files modified
setup.py (+1/-0) src/lazr/restful/docs/fields.rst (+8/-4) src/lazr/restful/docs/interface.rst (+2/-1) src/lazr/restful/docs/multiversion.rst (+10/-5) src/lazr/restful/docs/webservice-declarations.rst (+16/-13) src/lazr/restful/docs/webservice.rst (+16/-10) src/lazr/restful/example/base/tests/representation-cache.txt (+2/-1) src/lazr/restful/example/base/tests/test_integration.py (+7/-1) src/lazr/restful/example/base/tests/traversal.txt (+2/-1) src/lazr/restful/example/base_extended/tests/test_integration.py (+6/-1) src/lazr/restful/example/multiversion/tests/test_integration.py (+7/-2) src/lazr/restful/example/wsgi/tests/test_integration.py (+8/-2) src/lazr/restful/tests/test_docs.py (+5/-2) |
To merge this branch: | bzr merge lp:~cjwatson/lazr.restful/py3-normalize-doctests |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ioana Lasc (community) | Approve | ||
Review via email: mp+389665@code.launchpad.net |
Commit message
Make doctests of tracebacks work on both Python 2 and 3.
Description of the change
zope.testing.
To post a comment you must log in.
Revision history for this message
Ioana Lasc (ilasc) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'setup.py' |
2 | --- setup.py 2020-02-13 00:01:12 +0000 |
3 | +++ setup.py 2020-08-21 16:29:09 +0000 |
4 | @@ -88,6 +88,7 @@ |
5 | "Programming Language :: Python"], |
6 | extras_require=dict( |
7 | docs=['Sphinx'], |
8 | + test=['zope.testing>=4.6.0'], |
9 | xml=['lxml',] # requiring this of normal users is too much |
10 | ), |
11 | test_suite='lazr.restful.tests', |
12 | |
13 | === modified file 'src/lazr/restful/docs/fields.rst' |
14 | --- src/lazr/restful/docs/fields.rst 2019-11-04 09:54:43 +0000 |
15 | +++ src/lazr/restful/docs/fields.rst 2020-08-21 16:29:09 +0000 |
16 | @@ -43,16 +43,18 @@ |
17 | But if the object isn't iterable, NotAContainer is raised. |
18 | |
19 | >>> int_collection.validate(object()) |
20 | + ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 |
21 | Traceback (most recent call last): |
22 | ... |
23 | - NotAContainer: <object...> |
24 | + zope.schema._bootstrapinterfaces.NotAContainer: <object...> |
25 | |
26 | If the iterable contains an invalid item, WrongContainedType is raised. |
27 | |
28 | >>> int_collection.validate(['a', 1, 2, 'b']) |
29 | + ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 |
30 | Traceback (most recent call last): |
31 | ... |
32 | - WrongContainedType: ... |
33 | + zope.schema._bootstrapinterfaces.WrongContainedType: ... |
34 | |
35 | ========= |
36 | Reference |
37 | @@ -77,9 +79,10 @@ |
38 | ... pass |
39 | >>> fake = Fake() |
40 | >>> reference.validate(fake) |
41 | + ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 |
42 | Traceback (most recent call last): |
43 | ... |
44 | - SchemaNotProvided: ... |
45 | + zope.schema._bootstrapinterfaces.SchemaNotProvided: ... |
46 | |
47 | >>> directlyProvides(fake, MySchema) |
48 | >>> reference.validate(fake) |
49 | @@ -92,9 +95,10 @@ |
50 | |
51 | >>> fake.a_value = 'bad' |
52 | >>> reference.validate(fake) |
53 | + ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 |
54 | Traceback (most recent call last): |
55 | ... |
56 | - ConstraintNotSatisfied... |
57 | + zope.schema._bootstrapinterfaces.ConstraintNotSatisfied: ... |
58 | |
59 | >>> fake.a_value = 'good' |
60 | >>> reference.validate(fake) |
61 | |
62 | === modified file 'src/lazr/restful/docs/interface.rst' |
63 | --- src/lazr/restful/docs/interface.rst 2020-02-04 11:52:59 +0000 |
64 | +++ src/lazr/restful/docs/interface.rst 2020-08-21 16:29:09 +0000 |
65 | @@ -174,9 +174,10 @@ |
66 | raised: |
67 | |
68 | >>> copy_field(MyModel['age'], title='This should be unicode') |
69 | + ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 |
70 | Traceback (most recent call last): |
71 | ... |
72 | - WrongType: ... |
73 | + zope.schema._bootstrapinterfaces.WrongType: ... |
74 | |
75 | That function can only be called on an IField: |
76 | |
77 | |
78 | === modified file 'src/lazr/restful/docs/multiversion.rst' |
79 | --- src/lazr/restful/docs/multiversion.rst 2020-02-04 13:17:32 +0000 |
80 | +++ src/lazr/restful/docs/multiversion.rst 2020-08-21 16:29:09 +0000 |
81 | @@ -412,9 +412,10 @@ |
82 | >>> from zope.component import getAdapter |
83 | |
84 | >>> getAdapter(C1, IEntry) |
85 | + ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 |
86 | Traceback (most recent call last): |
87 | ... |
88 | - ComponentLookupError: ... |
89 | + zope.interface.interfaces.ComponentLookupError: ... |
90 | |
91 | When adapting Contact to IEntry you must provide a versioned request |
92 | object. The IEntry object you get back will implement the appropriate |
93 | @@ -792,9 +793,10 @@ |
94 | |
95 | >>> request = create_web_service_request('/1.0/contact_list') |
96 | >>> resource = request.traverse(None) |
97 | + ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 |
98 | Traceback (most recent call last): |
99 | ... |
100 | - NotFound: Object: <PostBetaServiceRootResource...>, name: u'contact_list' |
101 | + zope.publisher.interfaces.NotFound: Object: <PostBetaServiceRootResource...>, name: ...'contact_list' |
102 | |
103 | Here's the contact list under its correct URL. |
104 | |
105 | @@ -845,9 +847,10 @@ |
106 | >>> request_10 = create_web_service_request( |
107 | ... '/1.0/contacts/Cleo Python/fax') |
108 | >>> field = request_10.traverse(None) |
109 | + ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 |
110 | Traceback (most recent call last): |
111 | ... |
112 | - NotFound: Object: <Contact object...>, name: u'fax' |
113 | + zope.publisher.interfaces.NotFound: Object: <Contact object...>, name: ...'fax' |
114 | |
115 | We can invoke a named operation. Note that the name of the operation |
116 | is now 'find' (it was 'findContacts' in 'beta'). And note that |
117 | @@ -962,16 +965,18 @@ |
118 | >>> request_beta = create_web_service_request( |
119 | ... '/dev/contacts/Cleo Python/fax') |
120 | >>> field = request_beta.traverse(None) |
121 | + ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 |
122 | Traceback (most recent call last): |
123 | ... |
124 | - NotFound: Object: <Contact object...>, name: u'fax' |
125 | + zope.publisher.interfaces.NotFound: Object: <Contact object...>, name: ...'fax' |
126 | |
127 | >>> request_beta = create_web_service_request( |
128 | ... '/dev/contacts/Cleo Python/fax_number') |
129 | >>> field = request_beta.traverse(None) |
130 | + ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 |
131 | Traceback (most recent call last): |
132 | ... |
133 | - NotFound: Object: <Contact object...>, name: u'fax_number' |
134 | + zope.publisher.interfaces.NotFound: Object: <Contact object...>, name: ...'fax_number' |
135 | |
136 | We can invoke a named operation. |
137 | |
138 | |
139 | === modified file 'src/lazr/restful/docs/webservice-declarations.rst' |
140 | --- src/lazr/restful/docs/webservice-declarations.rst 2020-08-10 16:48:03 +0000 |
141 | +++ src/lazr/restful/docs/webservice-declarations.rst 2020-08-21 16:29:09 +0000 |
142 | @@ -2651,12 +2651,10 @@ |
143 | explaining the problem. |
144 | |
145 | >>> register_test_module('wrongorder', WrongOrderVersions) |
146 | + ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 |
147 | Traceback (most recent call last): |
148 | ... |
149 | - ConfigurationExecutionError: ...AssertionError... |
150 | - Annotations on "WrongOrderVersions.method" put an earlier version |
151 | - on top of a later version: "beta", "2.0", "1.0". The correct order |
152 | - is: "beta", "1.0", "2.0"... |
153 | + zope.configuration.config.ConfigurationExecutionError: ...AssertionError... Annotations on "WrongOrderVersions.method" put an earlier version on top of a later version: "beta", "2.0", "1.0". The correct order is: "beta", "1.0", "2.0"... |
154 | |
155 | Here's a class in which a named operation is removed in version 1.0 |
156 | and then annotated without being reinstated. |
157 | @@ -2673,11 +2671,10 @@ |
158 | ... """A method.""" |
159 | |
160 | >>> register_test_module('annotatingremoved', AnnotatingARemovedMethod) |
161 | + ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 |
162 | Traceback (most recent call last): |
163 | ... |
164 | - ConfigurationExecutionError: ... Method "method" contains |
165 | - annotations for version "2.0", even though it's not published in |
166 | - that version. The bad annotations are: "as", "params"... |
167 | + zope.configuration.config.ConfigurationExecutionError: ... Method "method" contains annotations for version "2.0", even though it's not published in that version. The bad annotations are: "as", "params"... |
168 | |
169 | Mutators as named operations |
170 | ---------------------------- |
171 | @@ -2745,9 +2742,10 @@ |
172 | named operations. |
173 | |
174 | >>> operation_for(context, '2.0', 'set_value') |
175 | + ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 |
176 | Traceback (most recent call last): |
177 | ... |
178 | - ComponentLookupError: ... |
179 | + zope.interface.interfaces.ComponentLookupError: ... |
180 | |
181 | Here's an entry that defines a mutator method in version 2.0, after |
182 | the cutoff point. |
183 | @@ -2777,14 +2775,16 @@ |
184 | |
185 | >>> context = Mutator20() |
186 | >>> operation_for(context, '1.0', 'set_value') |
187 | + ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 |
188 | Traceback (most recent call last): |
189 | ... |
190 | - ComponentLookupError: ... |
191 | + zope.interface.interfaces.ComponentLookupError: ... |
192 | |
193 | >>> operation_for(context, '2.0', 'set_value') |
194 | + ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 |
195 | Traceback (most recent call last): |
196 | ... |
197 | - ComponentLookupError: ... |
198 | + zope.interface.interfaces.ComponentLookupError: ... |
199 | |
200 | Edge cases |
201 | ========== |
202 | @@ -2826,9 +2826,10 @@ |
203 | defined yet. |
204 | |
205 | >>> print(operation_for(context, 'beta', 'set_value').__class__.__name__) |
206 | + ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 |
207 | Traceback (most recent call last): |
208 | ... |
209 | - ComponentLookupError: ... |
210 | + zope.interface.interfaces.ComponentLookupError: ... |
211 | |
212 | The operation is available in both '1.0', and '2.0', even though |
213 | mutator operations aren't published as named operations after |
214 | @@ -2845,9 +2846,10 @@ |
215 | a mutator. |
216 | |
217 | >>> operation_for(context, '3.0', 'set_value') |
218 | + ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 |
219 | Traceback (most recent call last): |
220 | ... |
221 | - ComponentLookupError: ... |
222 | + zope.interface.interfaces.ComponentLookupError: ... |
223 | |
224 | But the mutator is active, as you can see by modifying the entry's field: |
225 | |
226 | @@ -2958,9 +2960,10 @@ |
227 | |
228 | >>> context = BetaMutator2() |
229 | >>> operation_for(context, 'beta', 'set_value') |
230 | + ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 |
231 | Traceback (most recent call last): |
232 | ... |
233 | - ComponentLookupError: ... |
234 | + zope.interface.interfaces.ComponentLookupError: ... |
235 | |
236 | Getting the old behavior back |
237 | ----------------------------- |
238 | |
239 | === modified file 'src/lazr/restful/docs/webservice.rst' |
240 | --- src/lazr/restful/docs/webservice.rst 2020-08-17 11:46:51 +0000 |
241 | +++ src/lazr/restful/docs/webservice.rst 2020-08-21 16:29:09 +0000 |
242 | @@ -692,9 +692,10 @@ |
243 | >>> verifyObject(IAuthorEntry, InvalidAuthorEntry(A1, request)) |
244 | True |
245 | >>> IAuthorEntry.validateInvariants(InvalidAuthorEntry(A1, request)) |
246 | + ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 |
247 | Traceback (most recent call last): |
248 | ... |
249 | - Invalid: InvalidAuthorEntry doesn't provide its ICookbookEntry schema. |
250 | + zope.interface.exceptions.Invalid: InvalidAuthorEntry doesn't provide its ICookbookEntry schema. |
251 | |
252 | Other entries are defined similarly. |
253 | |
254 | @@ -1748,9 +1749,10 @@ |
255 | ... "Baked beans") |
256 | >>> get_request = create_web_service_request(private_recipe_url) |
257 | >>> recipe_resource = get_request.traverse(app) |
258 | + ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 |
259 | Traceback (most recent call last): |
260 | ... |
261 | - Unauthorized: (<Recipe object...>, 'dish', ...) |
262 | + zope.security.interfaces.Unauthorized: (<Recipe object...>, 'dish', ...) |
263 | |
264 | The recipe will not show up in collections: |
265 | |
266 | @@ -1858,10 +1860,10 @@ |
267 | >>> cover_url = quote('/beta/cookbooks/The Joy of Cooking/cover') |
268 | >>> get_request = create_web_service_request(cover_url) |
269 | >>> file_resource = get_request.traverse(app) |
270 | - >>> file_resource() |
271 | + >>> file_resource() # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 |
272 | Traceback (most recent call last): |
273 | ... |
274 | - NotFound: ... name: 'cover' |
275 | + zope.publisher.interfaces.NotFound: ... name: 'cover' |
276 | |
277 | >>> print(C2.cover) |
278 | None |
279 | @@ -1897,10 +1899,10 @@ |
280 | |
281 | >>> get_request = create_web_service_request(cover_url) |
282 | >>> file_resource = get_request.traverse(app) |
283 | - >>> file_resource() |
284 | + >>> file_resource() # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 |
285 | Traceback (most recent call last): |
286 | ... |
287 | - NotFound: ... name: 'cover' |
288 | + zope.publisher.interfaces.NotFound: ... name: 'cover' |
289 | |
290 | >>> print(C2.cover) |
291 | None |
292 | @@ -1924,24 +1926,27 @@ |
293 | Requesting a non-existent top-level collection: |
294 | |
295 | >>> create_web_service_request('/beta/nosuchcollection').traverse(app) |
296 | + ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 |
297 | Traceback (most recent call last): |
298 | ... |
299 | - NotFound: ... name: u'nosuchcollection' |
300 | + zope.publisher.interfaces.NotFound: ... name: ...'nosuchcollection' |
301 | |
302 | Requesting a non-existent cookbook: |
303 | |
304 | >>> create_web_service_request('/beta/cookbooks/104').traverse(app) |
305 | + ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 |
306 | Traceback (most recent call last): |
307 | ... |
308 | - NotFound: ... name: u'104' |
309 | + zope.publisher.interfaces.NotFound: ... name: ...'104' |
310 | |
311 | Requesting a non-existent comment: |
312 | |
313 | >>> create_web_service_request( |
314 | ... '/beta/cookbooks/The%20Joy%20of%20Cooking/comments/10').traverse(app) |
315 | + ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 |
316 | Traceback (most recent call last): |
317 | ... |
318 | - NotFound: ... name: u'comments/10' |
319 | + zope.publisher.interfaces.NotFound: ... name: ...'comments/10' |
320 | |
321 | Manipulating entries |
322 | ==================== |
323 | @@ -2108,9 +2113,10 @@ |
324 | |
325 | >>> resource = create_web_service_request( |
326 | ... recipe_url, method='GET').traverse(app) |
327 | + ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 |
328 | Traceback (most recent call last): |
329 | ... |
330 | - NotFound: ... name: u'recipes/Foies de voilaille en aspic' |
331 | + zope.publisher.interfaces.NotFound: ... name: ...'recipes/Foies de voilaille en aspic' |
332 | |
333 | |
334 | Within a template |
335 | |
336 | === modified file 'src/lazr/restful/example/base/tests/representation-cache.txt' |
337 | --- src/lazr/restful/example/base/tests/representation-cache.txt 2020-07-22 23:22:26 +0000 |
338 | +++ src/lazr/restful/example/base/tests/representation-cache.txt 2020-08-21 16:29:09 +0000 |
339 | @@ -13,9 +13,10 @@ |
340 | >>> from zope.component import getUtility |
341 | >>> from lazr.restful.interfaces import IRepresentationCache |
342 | >>> getUtility(IRepresentationCache) |
343 | + ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 |
344 | Traceback (most recent call last): |
345 | ... |
346 | - ComponentLookupError: ... |
347 | + zope.interface.interfaces.ComponentLookupError: ... |
348 | |
349 | DictionaryBasedRepresentationCache |
350 | ================================== |
351 | |
352 | === modified file 'src/lazr/restful/example/base/tests/test_integration.py' |
353 | --- src/lazr/restful/example/base/tests/test_integration.py 2020-02-04 11:52:59 +0000 |
354 | +++ src/lazr/restful/example/base/tests/test_integration.py 2020-08-21 16:29:09 +0000 |
355 | @@ -12,6 +12,7 @@ |
356 | from pkg_resources import resource_filename |
357 | |
358 | from van.testing.layer import zcml_layer, wsgi_intercept_layer |
359 | +from zope.testing import renormalizing |
360 | |
361 | from lazr.restful.example.base.root import CookbookServiceRootResource |
362 | from lazr.restful.testing.webservice import ( |
363 | @@ -28,6 +29,10 @@ |
364 | doctest.NORMALIZE_WHITESPACE | |
365 | doctest.REPORT_NDIFF) |
366 | |
367 | + |
368 | +checker = renormalizing.OutputChecker() |
369 | + |
370 | + |
371 | class FunctionalLayer: |
372 | allow_teardown = False |
373 | zcml = os.path.abspath(resource_filename('lazr.restful', 'ftesting.zcml')) |
374 | @@ -52,7 +57,8 @@ |
375 | 'print_function': print_function, |
376 | } |
377 | suite = doctest.DocFileSuite( |
378 | - *doctest_files, optionflags=DOCTEST_FLAGS, globs=globs) |
379 | + *doctest_files, optionflags=DOCTEST_FLAGS, globs=globs, |
380 | + checker=checker) |
381 | suite.layer = WSGILayer |
382 | tests.addTest(suite) |
383 | return tests |
384 | |
385 | === modified file 'src/lazr/restful/example/base/tests/traversal.txt' |
386 | --- src/lazr/restful/example/base/tests/traversal.txt 2009-09-01 13:10:07 +0000 |
387 | +++ src/lazr/restful/example/base/tests/traversal.txt 2020-08-21 16:29:09 +0000 |
388 | @@ -21,6 +21,7 @@ |
389 | error. |
390 | |
391 | >>> container.publishTraverse(request, "nosuchname") |
392 | + ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 |
393 | Traceback (most recent call last): |
394 | ... |
395 | - NotFound: ... name: 'nosuchname' |
396 | + zope.publisher.interfaces.NotFound: ... name: 'nosuchname' |
397 | |
398 | === modified file 'src/lazr/restful/example/base_extended/tests/test_integration.py' |
399 | --- src/lazr/restful/example/base_extended/tests/test_integration.py 2020-02-04 11:52:59 +0000 |
400 | +++ src/lazr/restful/example/base_extended/tests/test_integration.py 2020-08-21 16:29:09 +0000 |
401 | @@ -12,12 +12,16 @@ |
402 | from pkg_resources import resource_filename |
403 | |
404 | from van.testing.layer import zcml_layer, wsgi_intercept_layer |
405 | +from zope.testing import renormalizing |
406 | |
407 | from lazr.restful.example.base.tests.test_integration import ( |
408 | CookbookWebServiceTestPublication, DOCTEST_FLAGS) |
409 | from lazr.restful.testing.webservice import WebServiceApplication |
410 | |
411 | |
412 | +checker = renormalizing.OutputChecker() |
413 | + |
414 | + |
415 | class FunctionalLayer: |
416 | allow_teardown = False |
417 | zcml = os.path.abspath(resource_filename( |
418 | @@ -40,7 +44,8 @@ |
419 | 'print_function': print_function, |
420 | } |
421 | suite = doctest.DocFileSuite( |
422 | - *doctest_files, optionflags=DOCTEST_FLAGS, globs=globs) |
423 | + *doctest_files, optionflags=DOCTEST_FLAGS, globs=globs, |
424 | + checker=checker) |
425 | suite.layer = WSGILayer |
426 | tests.addTest(suite) |
427 | return tests |
428 | |
429 | === modified file 'src/lazr/restful/example/multiversion/tests/test_integration.py' |
430 | --- src/lazr/restful/example/multiversion/tests/test_integration.py 2020-02-04 11:52:59 +0000 |
431 | +++ src/lazr/restful/example/multiversion/tests/test_integration.py 2020-08-21 16:29:09 +0000 |
432 | @@ -11,8 +11,9 @@ |
433 | import doctest |
434 | from pkg_resources import resource_filename |
435 | |
436 | +from van.testing.layer import zcml_layer, wsgi_intercept_layer |
437 | from zope.component import getUtility |
438 | -from van.testing.layer import zcml_layer, wsgi_intercept_layer |
439 | +from zope.testing import renormalizing |
440 | |
441 | from lazr.restful.example.multiversion.root import ( |
442 | MultiversionWebServiceRootResource) |
443 | @@ -27,6 +28,9 @@ |
444 | doctest.REPORT_NDIFF) |
445 | |
446 | |
447 | +checker = renormalizing.OutputChecker() |
448 | + |
449 | + |
450 | class FunctionalLayer: |
451 | zcml = os.path.abspath(resource_filename( |
452 | 'lazr.restful.example.multiversion', 'site.zcml')) |
453 | @@ -55,7 +59,8 @@ |
454 | 'print_function': print_function, |
455 | } |
456 | suite = doctest.DocFileSuite( |
457 | - *doctest_files, optionflags=DOCTEST_FLAGS, globs=globs) |
458 | + *doctest_files, optionflags=DOCTEST_FLAGS, globs=globs, |
459 | + checker=checker) |
460 | suite.layer = WSGILayer |
461 | tests.addTest(suite) |
462 | return tests |
463 | |
464 | === modified file 'src/lazr/restful/example/wsgi/tests/test_integration.py' |
465 | --- src/lazr/restful/example/wsgi/tests/test_integration.py 2020-02-04 11:52:59 +0000 |
466 | +++ src/lazr/restful/example/wsgi/tests/test_integration.py 2020-08-21 16:29:09 +0000 |
467 | @@ -11,8 +11,9 @@ |
468 | import doctest |
469 | from pkg_resources import resource_filename |
470 | |
471 | +from van.testing.layer import zcml_layer, wsgi_intercept_layer |
472 | from zope.component import getUtility |
473 | -from van.testing.layer import zcml_layer, wsgi_intercept_layer |
474 | +from zope.testing import renormalizing |
475 | |
476 | from lazr.restful.example.wsgi.root import WSGIExampleWebServiceRootResource |
477 | from lazr.restful.interfaces import IWebServiceConfiguration |
478 | @@ -25,6 +26,10 @@ |
479 | doctest.NORMALIZE_WHITESPACE | |
480 | doctest.REPORT_NDIFF) |
481 | |
482 | + |
483 | +checker = renormalizing.OutputChecker() |
484 | + |
485 | + |
486 | class FunctionalLayer: |
487 | zcml = os.path.abspath(resource_filename( |
488 | 'lazr.restful.example.wsgi', 'site.zcml')) |
489 | @@ -52,7 +57,8 @@ |
490 | 'print_function': print_function, |
491 | } |
492 | suite = doctest.DocFileSuite( |
493 | - *doctest_files, optionflags=DOCTEST_FLAGS, globs=globs) |
494 | + *doctest_files, optionflags=DOCTEST_FLAGS, globs=globs, |
495 | + checker=checker) |
496 | suite.layer = WSGILayer |
497 | tests.addTest(suite) |
498 | return tests |
499 | |
500 | === modified file 'src/lazr/restful/tests/test_docs.py' |
501 | --- src/lazr/restful/tests/test_docs.py 2020-08-10 15:05:58 +0000 |
502 | +++ src/lazr/restful/tests/test_docs.py 2020-08-21 16:29:09 +0000 |
503 | @@ -27,7 +27,7 @@ |
504 | import os |
505 | from pkg_resources import ( |
506 | resource_filename, resource_exists, resource_listdir, cleanup_resources) |
507 | - |
508 | +from zope.testing import renormalizing |
509 | from zope.testing.cleanup import cleanUp |
510 | |
511 | |
512 | @@ -37,6 +37,9 @@ |
513 | doctest.REPORT_NDIFF) |
514 | |
515 | |
516 | +checker = renormalizing.OutputChecker() |
517 | + |
518 | + |
519 | def tearDown(test): |
520 | """Run registered clean-up function.""" |
521 | cleanUp() |
522 | @@ -58,5 +61,5 @@ |
523 | } |
524 | tests.addTest(doctest.DocFileSuite( |
525 | *doctest_files, module_relative=False, optionflags=DOCTEST_FLAGS, |
526 | - tearDown=tearDown, globs=globs, encoding='UTF-8')) |
527 | + tearDown=tearDown, globs=globs, encoding='UTF-8', checker=checker)) |
528 | return tests |