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 | 88 | "Programming Language :: Python"], | 88 | "Programming Language :: Python"], |
6 | 89 | extras_require=dict( | 89 | extras_require=dict( |
7 | 90 | docs=['Sphinx'], | 90 | docs=['Sphinx'], |
8 | 91 | test=['zope.testing>=4.6.0'], | ||
9 | 91 | xml=['lxml',] # requiring this of normal users is too much | 92 | xml=['lxml',] # requiring this of normal users is too much |
10 | 92 | ), | 93 | ), |
11 | 93 | test_suite='lazr.restful.tests', | 94 | test_suite='lazr.restful.tests', |
12 | 94 | 95 | ||
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 | 43 | But if the object isn't iterable, NotAContainer is raised. | 43 | But if the object isn't iterable, NotAContainer is raised. |
18 | 44 | 44 | ||
19 | 45 | >>> int_collection.validate(object()) | 45 | >>> int_collection.validate(object()) |
20 | 46 | ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 | ||
21 | 46 | Traceback (most recent call last): | 47 | Traceback (most recent call last): |
22 | 47 | ... | 48 | ... |
24 | 48 | NotAContainer: <object...> | 49 | zope.schema._bootstrapinterfaces.NotAContainer: <object...> |
25 | 49 | 50 | ||
26 | 50 | If the iterable contains an invalid item, WrongContainedType is raised. | 51 | If the iterable contains an invalid item, WrongContainedType is raised. |
27 | 51 | 52 | ||
28 | 52 | >>> int_collection.validate(['a', 1, 2, 'b']) | 53 | >>> int_collection.validate(['a', 1, 2, 'b']) |
29 | 54 | ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 | ||
30 | 53 | Traceback (most recent call last): | 55 | Traceback (most recent call last): |
31 | 54 | ... | 56 | ... |
33 | 55 | WrongContainedType: ... | 57 | zope.schema._bootstrapinterfaces.WrongContainedType: ... |
34 | 56 | 58 | ||
35 | 57 | ========= | 59 | ========= |
36 | 58 | Reference | 60 | Reference |
37 | @@ -77,9 +79,10 @@ | |||
38 | 77 | ... pass | 79 | ... pass |
39 | 78 | >>> fake = Fake() | 80 | >>> fake = Fake() |
40 | 79 | >>> reference.validate(fake) | 81 | >>> reference.validate(fake) |
41 | 82 | ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 | ||
42 | 80 | Traceback (most recent call last): | 83 | Traceback (most recent call last): |
43 | 81 | ... | 84 | ... |
45 | 82 | SchemaNotProvided: ... | 85 | zope.schema._bootstrapinterfaces.SchemaNotProvided: ... |
46 | 83 | 86 | ||
47 | 84 | >>> directlyProvides(fake, MySchema) | 87 | >>> directlyProvides(fake, MySchema) |
48 | 85 | >>> reference.validate(fake) | 88 | >>> reference.validate(fake) |
49 | @@ -92,9 +95,10 @@ | |||
50 | 92 | 95 | ||
51 | 93 | >>> fake.a_value = 'bad' | 96 | >>> fake.a_value = 'bad' |
52 | 94 | >>> reference.validate(fake) | 97 | >>> reference.validate(fake) |
53 | 98 | ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 | ||
54 | 95 | Traceback (most recent call last): | 99 | Traceback (most recent call last): |
55 | 96 | ... | 100 | ... |
57 | 97 | ConstraintNotSatisfied... | 101 | zope.schema._bootstrapinterfaces.ConstraintNotSatisfied: ... |
58 | 98 | 102 | ||
59 | 99 | >>> fake.a_value = 'good' | 103 | >>> fake.a_value = 'good' |
60 | 100 | >>> reference.validate(fake) | 104 | >>> reference.validate(fake) |
61 | 101 | 105 | ||
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 | 174 | raised: | 174 | raised: |
67 | 175 | 175 | ||
68 | 176 | >>> copy_field(MyModel['age'], title='This should be unicode') | 176 | >>> copy_field(MyModel['age'], title='This should be unicode') |
69 | 177 | ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 | ||
70 | 177 | Traceback (most recent call last): | 178 | Traceback (most recent call last): |
71 | 178 | ... | 179 | ... |
73 | 179 | WrongType: ... | 180 | zope.schema._bootstrapinterfaces.WrongType: ... |
74 | 180 | 181 | ||
75 | 181 | That function can only be called on an IField: | 182 | That function can only be called on an IField: |
76 | 182 | 183 | ||
77 | 183 | 184 | ||
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 | 412 | >>> from zope.component import getAdapter | 412 | >>> from zope.component import getAdapter |
83 | 413 | 413 | ||
84 | 414 | >>> getAdapter(C1, IEntry) | 414 | >>> getAdapter(C1, IEntry) |
85 | 415 | ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 | ||
86 | 415 | Traceback (most recent call last): | 416 | Traceback (most recent call last): |
87 | 416 | ... | 417 | ... |
89 | 417 | ComponentLookupError: ... | 418 | zope.interface.interfaces.ComponentLookupError: ... |
90 | 418 | 419 | ||
91 | 419 | When adapting Contact to IEntry you must provide a versioned request | 420 | When adapting Contact to IEntry you must provide a versioned request |
92 | 420 | object. The IEntry object you get back will implement the appropriate | 421 | object. The IEntry object you get back will implement the appropriate |
93 | @@ -792,9 +793,10 @@ | |||
94 | 792 | 793 | ||
95 | 793 | >>> request = create_web_service_request('/1.0/contact_list') | 794 | >>> request = create_web_service_request('/1.0/contact_list') |
96 | 794 | >>> resource = request.traverse(None) | 795 | >>> resource = request.traverse(None) |
97 | 796 | ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 | ||
98 | 795 | Traceback (most recent call last): | 797 | Traceback (most recent call last): |
99 | 796 | ... | 798 | ... |
101 | 797 | NotFound: Object: <PostBetaServiceRootResource...>, name: u'contact_list' | 799 | zope.publisher.interfaces.NotFound: Object: <PostBetaServiceRootResource...>, name: ...'contact_list' |
102 | 798 | 800 | ||
103 | 799 | Here's the contact list under its correct URL. | 801 | Here's the contact list under its correct URL. |
104 | 800 | 802 | ||
105 | @@ -845,9 +847,10 @@ | |||
106 | 845 | >>> request_10 = create_web_service_request( | 847 | >>> request_10 = create_web_service_request( |
107 | 846 | ... '/1.0/contacts/Cleo Python/fax') | 848 | ... '/1.0/contacts/Cleo Python/fax') |
108 | 847 | >>> field = request_10.traverse(None) | 849 | >>> field = request_10.traverse(None) |
109 | 850 | ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 | ||
110 | 848 | Traceback (most recent call last): | 851 | Traceback (most recent call last): |
111 | 849 | ... | 852 | ... |
113 | 850 | NotFound: Object: <Contact object...>, name: u'fax' | 853 | zope.publisher.interfaces.NotFound: Object: <Contact object...>, name: ...'fax' |
114 | 851 | 854 | ||
115 | 852 | We can invoke a named operation. Note that the name of the operation | 855 | We can invoke a named operation. Note that the name of the operation |
116 | 853 | is now 'find' (it was 'findContacts' in 'beta'). And note that | 856 | is now 'find' (it was 'findContacts' in 'beta'). And note that |
117 | @@ -962,16 +965,18 @@ | |||
118 | 962 | >>> request_beta = create_web_service_request( | 965 | >>> request_beta = create_web_service_request( |
119 | 963 | ... '/dev/contacts/Cleo Python/fax') | 966 | ... '/dev/contacts/Cleo Python/fax') |
120 | 964 | >>> field = request_beta.traverse(None) | 967 | >>> field = request_beta.traverse(None) |
121 | 968 | ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 | ||
122 | 965 | Traceback (most recent call last): | 969 | Traceback (most recent call last): |
123 | 966 | ... | 970 | ... |
125 | 967 | NotFound: Object: <Contact object...>, name: u'fax' | 971 | zope.publisher.interfaces.NotFound: Object: <Contact object...>, name: ...'fax' |
126 | 968 | 972 | ||
127 | 969 | >>> request_beta = create_web_service_request( | 973 | >>> request_beta = create_web_service_request( |
128 | 970 | ... '/dev/contacts/Cleo Python/fax_number') | 974 | ... '/dev/contacts/Cleo Python/fax_number') |
129 | 971 | >>> field = request_beta.traverse(None) | 975 | >>> field = request_beta.traverse(None) |
130 | 976 | ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 | ||
131 | 972 | Traceback (most recent call last): | 977 | Traceback (most recent call last): |
132 | 973 | ... | 978 | ... |
134 | 974 | NotFound: Object: <Contact object...>, name: u'fax_number' | 979 | zope.publisher.interfaces.NotFound: Object: <Contact object...>, name: ...'fax_number' |
135 | 975 | 980 | ||
136 | 976 | We can invoke a named operation. | 981 | We can invoke a named operation. |
137 | 977 | 982 | ||
138 | 978 | 983 | ||
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 | 2651 | explaining the problem. | 2651 | explaining the problem. |
144 | 2652 | 2652 | ||
145 | 2653 | >>> register_test_module('wrongorder', WrongOrderVersions) | 2653 | >>> register_test_module('wrongorder', WrongOrderVersions) |
146 | 2654 | ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 | ||
147 | 2654 | Traceback (most recent call last): | 2655 | Traceback (most recent call last): |
148 | 2655 | ... | 2656 | ... |
153 | 2656 | ConfigurationExecutionError: ...AssertionError... | 2657 | 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"... |
150 | 2657 | Annotations on "WrongOrderVersions.method" put an earlier version | ||
151 | 2658 | on top of a later version: "beta", "2.0", "1.0". The correct order | ||
152 | 2659 | is: "beta", "1.0", "2.0"... | ||
154 | 2660 | 2658 | ||
155 | 2661 | Here's a class in which a named operation is removed in version 1.0 | 2659 | Here's a class in which a named operation is removed in version 1.0 |
156 | 2662 | and then annotated without being reinstated. | 2660 | and then annotated without being reinstated. |
157 | @@ -2673,11 +2671,10 @@ | |||
158 | 2673 | ... """A method.""" | 2671 | ... """A method.""" |
159 | 2674 | 2672 | ||
160 | 2675 | >>> register_test_module('annotatingremoved', AnnotatingARemovedMethod) | 2673 | >>> register_test_module('annotatingremoved', AnnotatingARemovedMethod) |
161 | 2674 | ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 | ||
162 | 2676 | Traceback (most recent call last): | 2675 | Traceback (most recent call last): |
163 | 2677 | ... | 2676 | ... |
167 | 2678 | ConfigurationExecutionError: ... Method "method" contains | 2677 | 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"... |
165 | 2679 | annotations for version "2.0", even though it's not published in | ||
166 | 2680 | that version. The bad annotations are: "as", "params"... | ||
168 | 2681 | 2678 | ||
169 | 2682 | Mutators as named operations | 2679 | Mutators as named operations |
170 | 2683 | ---------------------------- | 2680 | ---------------------------- |
171 | @@ -2745,9 +2742,10 @@ | |||
172 | 2745 | named operations. | 2742 | named operations. |
173 | 2746 | 2743 | ||
174 | 2747 | >>> operation_for(context, '2.0', 'set_value') | 2744 | >>> operation_for(context, '2.0', 'set_value') |
175 | 2745 | ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 | ||
176 | 2748 | Traceback (most recent call last): | 2746 | Traceback (most recent call last): |
177 | 2749 | ... | 2747 | ... |
179 | 2750 | ComponentLookupError: ... | 2748 | zope.interface.interfaces.ComponentLookupError: ... |
180 | 2751 | 2749 | ||
181 | 2752 | Here's an entry that defines a mutator method in version 2.0, after | 2750 | Here's an entry that defines a mutator method in version 2.0, after |
182 | 2753 | the cutoff point. | 2751 | the cutoff point. |
183 | @@ -2777,14 +2775,16 @@ | |||
184 | 2777 | 2775 | ||
185 | 2778 | >>> context = Mutator20() | 2776 | >>> context = Mutator20() |
186 | 2779 | >>> operation_for(context, '1.0', 'set_value') | 2777 | >>> operation_for(context, '1.0', 'set_value') |
187 | 2778 | ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 | ||
188 | 2780 | Traceback (most recent call last): | 2779 | Traceback (most recent call last): |
189 | 2781 | ... | 2780 | ... |
191 | 2782 | ComponentLookupError: ... | 2781 | zope.interface.interfaces.ComponentLookupError: ... |
192 | 2783 | 2782 | ||
193 | 2784 | >>> operation_for(context, '2.0', 'set_value') | 2783 | >>> operation_for(context, '2.0', 'set_value') |
194 | 2784 | ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 | ||
195 | 2785 | Traceback (most recent call last): | 2785 | Traceback (most recent call last): |
196 | 2786 | ... | 2786 | ... |
198 | 2787 | ComponentLookupError: ... | 2787 | zope.interface.interfaces.ComponentLookupError: ... |
199 | 2788 | 2788 | ||
200 | 2789 | Edge cases | 2789 | Edge cases |
201 | 2790 | ========== | 2790 | ========== |
202 | @@ -2826,9 +2826,10 @@ | |||
203 | 2826 | defined yet. | 2826 | defined yet. |
204 | 2827 | 2827 | ||
205 | 2828 | >>> print(operation_for(context, 'beta', 'set_value').__class__.__name__) | 2828 | >>> print(operation_for(context, 'beta', 'set_value').__class__.__name__) |
206 | 2829 | ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 | ||
207 | 2829 | Traceback (most recent call last): | 2830 | Traceback (most recent call last): |
208 | 2830 | ... | 2831 | ... |
210 | 2831 | ComponentLookupError: ... | 2832 | zope.interface.interfaces.ComponentLookupError: ... |
211 | 2832 | 2833 | ||
212 | 2833 | The operation is available in both '1.0', and '2.0', even though | 2834 | The operation is available in both '1.0', and '2.0', even though |
213 | 2834 | mutator operations aren't published as named operations after | 2835 | mutator operations aren't published as named operations after |
214 | @@ -2845,9 +2846,10 @@ | |||
215 | 2845 | a mutator. | 2846 | a mutator. |
216 | 2846 | 2847 | ||
217 | 2847 | >>> operation_for(context, '3.0', 'set_value') | 2848 | >>> operation_for(context, '3.0', 'set_value') |
218 | 2849 | ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 | ||
219 | 2848 | Traceback (most recent call last): | 2850 | Traceback (most recent call last): |
220 | 2849 | ... | 2851 | ... |
222 | 2850 | ComponentLookupError: ... | 2852 | zope.interface.interfaces.ComponentLookupError: ... |
223 | 2851 | 2853 | ||
224 | 2852 | But the mutator is active, as you can see by modifying the entry's field: | 2854 | But the mutator is active, as you can see by modifying the entry's field: |
225 | 2853 | 2855 | ||
226 | @@ -2958,9 +2960,10 @@ | |||
227 | 2958 | 2960 | ||
228 | 2959 | >>> context = BetaMutator2() | 2961 | >>> context = BetaMutator2() |
229 | 2960 | >>> operation_for(context, 'beta', 'set_value') | 2962 | >>> operation_for(context, 'beta', 'set_value') |
230 | 2963 | ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 | ||
231 | 2961 | Traceback (most recent call last): | 2964 | Traceback (most recent call last): |
232 | 2962 | ... | 2965 | ... |
234 | 2963 | ComponentLookupError: ... | 2966 | zope.interface.interfaces.ComponentLookupError: ... |
235 | 2964 | 2967 | ||
236 | 2965 | Getting the old behavior back | 2968 | Getting the old behavior back |
237 | 2966 | ----------------------------- | 2969 | ----------------------------- |
238 | 2967 | 2970 | ||
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 | 692 | >>> verifyObject(IAuthorEntry, InvalidAuthorEntry(A1, request)) | 692 | >>> verifyObject(IAuthorEntry, InvalidAuthorEntry(A1, request)) |
244 | 693 | True | 693 | True |
245 | 694 | >>> IAuthorEntry.validateInvariants(InvalidAuthorEntry(A1, request)) | 694 | >>> IAuthorEntry.validateInvariants(InvalidAuthorEntry(A1, request)) |
246 | 695 | ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 | ||
247 | 695 | Traceback (most recent call last): | 696 | Traceback (most recent call last): |
248 | 696 | ... | 697 | ... |
250 | 697 | Invalid: InvalidAuthorEntry doesn't provide its ICookbookEntry schema. | 698 | zope.interface.exceptions.Invalid: InvalidAuthorEntry doesn't provide its ICookbookEntry schema. |
251 | 698 | 699 | ||
252 | 699 | Other entries are defined similarly. | 700 | Other entries are defined similarly. |
253 | 700 | 701 | ||
254 | @@ -1748,9 +1749,10 @@ | |||
255 | 1748 | ... "Baked beans") | 1749 | ... "Baked beans") |
256 | 1749 | >>> get_request = create_web_service_request(private_recipe_url) | 1750 | >>> get_request = create_web_service_request(private_recipe_url) |
257 | 1750 | >>> recipe_resource = get_request.traverse(app) | 1751 | >>> recipe_resource = get_request.traverse(app) |
258 | 1752 | ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 | ||
259 | 1751 | Traceback (most recent call last): | 1753 | Traceback (most recent call last): |
260 | 1752 | ... | 1754 | ... |
262 | 1753 | Unauthorized: (<Recipe object...>, 'dish', ...) | 1755 | zope.security.interfaces.Unauthorized: (<Recipe object...>, 'dish', ...) |
263 | 1754 | 1756 | ||
264 | 1755 | The recipe will not show up in collections: | 1757 | The recipe will not show up in collections: |
265 | 1756 | 1758 | ||
266 | @@ -1858,10 +1860,10 @@ | |||
267 | 1858 | >>> cover_url = quote('/beta/cookbooks/The Joy of Cooking/cover') | 1860 | >>> cover_url = quote('/beta/cookbooks/The Joy of Cooking/cover') |
268 | 1859 | >>> get_request = create_web_service_request(cover_url) | 1861 | >>> get_request = create_web_service_request(cover_url) |
269 | 1860 | >>> file_resource = get_request.traverse(app) | 1862 | >>> file_resource = get_request.traverse(app) |
271 | 1861 | >>> file_resource() | 1863 | >>> file_resource() # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 |
272 | 1862 | Traceback (most recent call last): | 1864 | Traceback (most recent call last): |
273 | 1863 | ... | 1865 | ... |
275 | 1864 | NotFound: ... name: 'cover' | 1866 | zope.publisher.interfaces.NotFound: ... name: 'cover' |
276 | 1865 | 1867 | ||
277 | 1866 | >>> print(C2.cover) | 1868 | >>> print(C2.cover) |
278 | 1867 | None | 1869 | None |
279 | @@ -1897,10 +1899,10 @@ | |||
280 | 1897 | 1899 | ||
281 | 1898 | >>> get_request = create_web_service_request(cover_url) | 1900 | >>> get_request = create_web_service_request(cover_url) |
282 | 1899 | >>> file_resource = get_request.traverse(app) | 1901 | >>> file_resource = get_request.traverse(app) |
284 | 1900 | >>> file_resource() | 1902 | >>> file_resource() # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 |
285 | 1901 | Traceback (most recent call last): | 1903 | Traceback (most recent call last): |
286 | 1902 | ... | 1904 | ... |
288 | 1903 | NotFound: ... name: 'cover' | 1905 | zope.publisher.interfaces.NotFound: ... name: 'cover' |
289 | 1904 | 1906 | ||
290 | 1905 | >>> print(C2.cover) | 1907 | >>> print(C2.cover) |
291 | 1906 | None | 1908 | None |
292 | @@ -1924,24 +1926,27 @@ | |||
293 | 1924 | Requesting a non-existent top-level collection: | 1926 | Requesting a non-existent top-level collection: |
294 | 1925 | 1927 | ||
295 | 1926 | >>> create_web_service_request('/beta/nosuchcollection').traverse(app) | 1928 | >>> create_web_service_request('/beta/nosuchcollection').traverse(app) |
296 | 1929 | ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 | ||
297 | 1927 | Traceback (most recent call last): | 1930 | Traceback (most recent call last): |
298 | 1928 | ... | 1931 | ... |
300 | 1929 | NotFound: ... name: u'nosuchcollection' | 1932 | zope.publisher.interfaces.NotFound: ... name: ...'nosuchcollection' |
301 | 1930 | 1933 | ||
302 | 1931 | Requesting a non-existent cookbook: | 1934 | Requesting a non-existent cookbook: |
303 | 1932 | 1935 | ||
304 | 1933 | >>> create_web_service_request('/beta/cookbooks/104').traverse(app) | 1936 | >>> create_web_service_request('/beta/cookbooks/104').traverse(app) |
305 | 1937 | ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 | ||
306 | 1934 | Traceback (most recent call last): | 1938 | Traceback (most recent call last): |
307 | 1935 | ... | 1939 | ... |
309 | 1936 | NotFound: ... name: u'104' | 1940 | zope.publisher.interfaces.NotFound: ... name: ...'104' |
310 | 1937 | 1941 | ||
311 | 1938 | Requesting a non-existent comment: | 1942 | Requesting a non-existent comment: |
312 | 1939 | 1943 | ||
313 | 1940 | >>> create_web_service_request( | 1944 | >>> create_web_service_request( |
314 | 1941 | ... '/beta/cookbooks/The%20Joy%20of%20Cooking/comments/10').traverse(app) | 1945 | ... '/beta/cookbooks/The%20Joy%20of%20Cooking/comments/10').traverse(app) |
315 | 1946 | ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 | ||
316 | 1942 | Traceback (most recent call last): | 1947 | Traceback (most recent call last): |
317 | 1943 | ... | 1948 | ... |
319 | 1944 | NotFound: ... name: u'comments/10' | 1949 | zope.publisher.interfaces.NotFound: ... name: ...'comments/10' |
320 | 1945 | 1950 | ||
321 | 1946 | Manipulating entries | 1951 | Manipulating entries |
322 | 1947 | ==================== | 1952 | ==================== |
323 | @@ -2108,9 +2113,10 @@ | |||
324 | 2108 | 2113 | ||
325 | 2109 | >>> resource = create_web_service_request( | 2114 | >>> resource = create_web_service_request( |
326 | 2110 | ... recipe_url, method='GET').traverse(app) | 2115 | ... recipe_url, method='GET').traverse(app) |
327 | 2116 | ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 | ||
328 | 2111 | Traceback (most recent call last): | 2117 | Traceback (most recent call last): |
329 | 2112 | ... | 2118 | ... |
331 | 2113 | NotFound: ... name: u'recipes/Foies de voilaille en aspic' | 2119 | zope.publisher.interfaces.NotFound: ... name: ...'recipes/Foies de voilaille en aspic' |
332 | 2114 | 2120 | ||
333 | 2115 | 2121 | ||
334 | 2116 | Within a template | 2122 | Within a template |
335 | 2117 | 2123 | ||
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 | 13 | >>> from zope.component import getUtility | 13 | >>> from zope.component import getUtility |
341 | 14 | >>> from lazr.restful.interfaces import IRepresentationCache | 14 | >>> from lazr.restful.interfaces import IRepresentationCache |
342 | 15 | >>> getUtility(IRepresentationCache) | 15 | >>> getUtility(IRepresentationCache) |
343 | 16 | ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 | ||
344 | 16 | Traceback (most recent call last): | 17 | Traceback (most recent call last): |
345 | 17 | ... | 18 | ... |
347 | 18 | ComponentLookupError: ... | 19 | zope.interface.interfaces.ComponentLookupError: ... |
348 | 19 | 20 | ||
349 | 20 | DictionaryBasedRepresentationCache | 21 | DictionaryBasedRepresentationCache |
350 | 21 | ================================== | 22 | ================================== |
351 | 22 | 23 | ||
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 | 12 | from pkg_resources import resource_filename | 12 | from pkg_resources import resource_filename |
357 | 13 | 13 | ||
358 | 14 | from van.testing.layer import zcml_layer, wsgi_intercept_layer | 14 | from van.testing.layer import zcml_layer, wsgi_intercept_layer |
359 | 15 | from zope.testing import renormalizing | ||
360 | 15 | 16 | ||
361 | 16 | from lazr.restful.example.base.root import CookbookServiceRootResource | 17 | from lazr.restful.example.base.root import CookbookServiceRootResource |
362 | 17 | from lazr.restful.testing.webservice import ( | 18 | from lazr.restful.testing.webservice import ( |
363 | @@ -28,6 +29,10 @@ | |||
364 | 28 | doctest.NORMALIZE_WHITESPACE | | 29 | doctest.NORMALIZE_WHITESPACE | |
365 | 29 | doctest.REPORT_NDIFF) | 30 | doctest.REPORT_NDIFF) |
366 | 30 | 31 | ||
367 | 32 | |||
368 | 33 | checker = renormalizing.OutputChecker() | ||
369 | 34 | |||
370 | 35 | |||
371 | 31 | class FunctionalLayer: | 36 | class FunctionalLayer: |
372 | 32 | allow_teardown = False | 37 | allow_teardown = False |
373 | 33 | zcml = os.path.abspath(resource_filename('lazr.restful', 'ftesting.zcml')) | 38 | zcml = os.path.abspath(resource_filename('lazr.restful', 'ftesting.zcml')) |
374 | @@ -52,7 +57,8 @@ | |||
375 | 52 | 'print_function': print_function, | 57 | 'print_function': print_function, |
376 | 53 | } | 58 | } |
377 | 54 | suite = doctest.DocFileSuite( | 59 | suite = doctest.DocFileSuite( |
379 | 55 | *doctest_files, optionflags=DOCTEST_FLAGS, globs=globs) | 60 | *doctest_files, optionflags=DOCTEST_FLAGS, globs=globs, |
380 | 61 | checker=checker) | ||
381 | 56 | suite.layer = WSGILayer | 62 | suite.layer = WSGILayer |
382 | 57 | tests.addTest(suite) | 63 | tests.addTest(suite) |
383 | 58 | return tests | 64 | return tests |
384 | 59 | 65 | ||
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 | 21 | error. | 21 | error. |
390 | 22 | 22 | ||
391 | 23 | >>> container.publishTraverse(request, "nosuchname") | 23 | >>> container.publishTraverse(request, "nosuchname") |
392 | 24 | ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2 | ||
393 | 24 | Traceback (most recent call last): | 25 | Traceback (most recent call last): |
394 | 25 | ... | 26 | ... |
396 | 26 | NotFound: ... name: 'nosuchname' | 27 | zope.publisher.interfaces.NotFound: ... name: 'nosuchname' |
397 | 27 | 28 | ||
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 | 12 | from pkg_resources import resource_filename | 12 | from pkg_resources import resource_filename |
403 | 13 | 13 | ||
404 | 14 | from van.testing.layer import zcml_layer, wsgi_intercept_layer | 14 | from van.testing.layer import zcml_layer, wsgi_intercept_layer |
405 | 15 | from zope.testing import renormalizing | ||
406 | 15 | 16 | ||
407 | 16 | from lazr.restful.example.base.tests.test_integration import ( | 17 | from lazr.restful.example.base.tests.test_integration import ( |
408 | 17 | CookbookWebServiceTestPublication, DOCTEST_FLAGS) | 18 | CookbookWebServiceTestPublication, DOCTEST_FLAGS) |
409 | 18 | from lazr.restful.testing.webservice import WebServiceApplication | 19 | from lazr.restful.testing.webservice import WebServiceApplication |
410 | 19 | 20 | ||
411 | 20 | 21 | ||
412 | 22 | checker = renormalizing.OutputChecker() | ||
413 | 23 | |||
414 | 24 | |||
415 | 21 | class FunctionalLayer: | 25 | class FunctionalLayer: |
416 | 22 | allow_teardown = False | 26 | allow_teardown = False |
417 | 23 | zcml = os.path.abspath(resource_filename( | 27 | zcml = os.path.abspath(resource_filename( |
418 | @@ -40,7 +44,8 @@ | |||
419 | 40 | 'print_function': print_function, | 44 | 'print_function': print_function, |
420 | 41 | } | 45 | } |
421 | 42 | suite = doctest.DocFileSuite( | 46 | suite = doctest.DocFileSuite( |
423 | 43 | *doctest_files, optionflags=DOCTEST_FLAGS, globs=globs) | 47 | *doctest_files, optionflags=DOCTEST_FLAGS, globs=globs, |
424 | 48 | checker=checker) | ||
425 | 44 | suite.layer = WSGILayer | 49 | suite.layer = WSGILayer |
426 | 45 | tests.addTest(suite) | 50 | tests.addTest(suite) |
427 | 46 | return tests | 51 | return tests |
428 | 47 | 52 | ||
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 | 11 | import doctest | 11 | import doctest |
434 | 12 | from pkg_resources import resource_filename | 12 | from pkg_resources import resource_filename |
435 | 13 | 13 | ||
436 | 14 | from van.testing.layer import zcml_layer, wsgi_intercept_layer | ||
437 | 14 | from zope.component import getUtility | 15 | from zope.component import getUtility |
439 | 15 | from van.testing.layer import zcml_layer, wsgi_intercept_layer | 16 | from zope.testing import renormalizing |
440 | 16 | 17 | ||
441 | 17 | from lazr.restful.example.multiversion.root import ( | 18 | from lazr.restful.example.multiversion.root import ( |
442 | 18 | MultiversionWebServiceRootResource) | 19 | MultiversionWebServiceRootResource) |
443 | @@ -27,6 +28,9 @@ | |||
444 | 27 | doctest.REPORT_NDIFF) | 28 | doctest.REPORT_NDIFF) |
445 | 28 | 29 | ||
446 | 29 | 30 | ||
447 | 31 | checker = renormalizing.OutputChecker() | ||
448 | 32 | |||
449 | 33 | |||
450 | 30 | class FunctionalLayer: | 34 | class FunctionalLayer: |
451 | 31 | zcml = os.path.abspath(resource_filename( | 35 | zcml = os.path.abspath(resource_filename( |
452 | 32 | 'lazr.restful.example.multiversion', 'site.zcml')) | 36 | 'lazr.restful.example.multiversion', 'site.zcml')) |
453 | @@ -55,7 +59,8 @@ | |||
454 | 55 | 'print_function': print_function, | 59 | 'print_function': print_function, |
455 | 56 | } | 60 | } |
456 | 57 | suite = doctest.DocFileSuite( | 61 | suite = doctest.DocFileSuite( |
458 | 58 | *doctest_files, optionflags=DOCTEST_FLAGS, globs=globs) | 62 | *doctest_files, optionflags=DOCTEST_FLAGS, globs=globs, |
459 | 63 | checker=checker) | ||
460 | 59 | suite.layer = WSGILayer | 64 | suite.layer = WSGILayer |
461 | 60 | tests.addTest(suite) | 65 | tests.addTest(suite) |
462 | 61 | return tests | 66 | return tests |
463 | 62 | 67 | ||
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 | 11 | import doctest | 11 | import doctest |
469 | 12 | from pkg_resources import resource_filename | 12 | from pkg_resources import resource_filename |
470 | 13 | 13 | ||
471 | 14 | from van.testing.layer import zcml_layer, wsgi_intercept_layer | ||
472 | 14 | from zope.component import getUtility | 15 | from zope.component import getUtility |
474 | 15 | from van.testing.layer import zcml_layer, wsgi_intercept_layer | 16 | from zope.testing import renormalizing |
475 | 16 | 17 | ||
476 | 17 | from lazr.restful.example.wsgi.root import WSGIExampleWebServiceRootResource | 18 | from lazr.restful.example.wsgi.root import WSGIExampleWebServiceRootResource |
477 | 18 | from lazr.restful.interfaces import IWebServiceConfiguration | 19 | from lazr.restful.interfaces import IWebServiceConfiguration |
478 | @@ -25,6 +26,10 @@ | |||
479 | 25 | doctest.NORMALIZE_WHITESPACE | | 26 | doctest.NORMALIZE_WHITESPACE | |
480 | 26 | doctest.REPORT_NDIFF) | 27 | doctest.REPORT_NDIFF) |
481 | 27 | 28 | ||
482 | 29 | |||
483 | 30 | checker = renormalizing.OutputChecker() | ||
484 | 31 | |||
485 | 32 | |||
486 | 28 | class FunctionalLayer: | 33 | class FunctionalLayer: |
487 | 29 | zcml = os.path.abspath(resource_filename( | 34 | zcml = os.path.abspath(resource_filename( |
488 | 30 | 'lazr.restful.example.wsgi', 'site.zcml')) | 35 | 'lazr.restful.example.wsgi', 'site.zcml')) |
489 | @@ -52,7 +57,8 @@ | |||
490 | 52 | 'print_function': print_function, | 57 | 'print_function': print_function, |
491 | 53 | } | 58 | } |
492 | 54 | suite = doctest.DocFileSuite( | 59 | suite = doctest.DocFileSuite( |
494 | 55 | *doctest_files, optionflags=DOCTEST_FLAGS, globs=globs) | 60 | *doctest_files, optionflags=DOCTEST_FLAGS, globs=globs, |
495 | 61 | checker=checker) | ||
496 | 56 | suite.layer = WSGILayer | 62 | suite.layer = WSGILayer |
497 | 57 | tests.addTest(suite) | 63 | tests.addTest(suite) |
498 | 58 | return tests | 64 | return tests |
499 | 59 | 65 | ||
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 | 27 | import os | 27 | import os |
505 | 28 | from pkg_resources import ( | 28 | from pkg_resources import ( |
506 | 29 | resource_filename, resource_exists, resource_listdir, cleanup_resources) | 29 | resource_filename, resource_exists, resource_listdir, cleanup_resources) |
508 | 30 | 30 | from zope.testing import renormalizing | |
509 | 31 | from zope.testing.cleanup import cleanUp | 31 | from zope.testing.cleanup import cleanUp |
510 | 32 | 32 | ||
511 | 33 | 33 | ||
512 | @@ -37,6 +37,9 @@ | |||
513 | 37 | doctest.REPORT_NDIFF) | 37 | doctest.REPORT_NDIFF) |
514 | 38 | 38 | ||
515 | 39 | 39 | ||
516 | 40 | checker = renormalizing.OutputChecker() | ||
517 | 41 | |||
518 | 42 | |||
519 | 40 | def tearDown(test): | 43 | def tearDown(test): |
520 | 41 | """Run registered clean-up function.""" | 44 | """Run registered clean-up function.""" |
521 | 42 | cleanUp() | 45 | cleanUp() |
522 | @@ -58,5 +61,5 @@ | |||
523 | 58 | } | 61 | } |
524 | 59 | tests.addTest(doctest.DocFileSuite( | 62 | tests.addTest(doctest.DocFileSuite( |
525 | 60 | *doctest_files, module_relative=False, optionflags=DOCTEST_FLAGS, | 63 | *doctest_files, module_relative=False, optionflags=DOCTEST_FLAGS, |
527 | 61 | tearDown=tearDown, globs=globs, encoding='UTF-8')) | 64 | tearDown=tearDown, globs=globs, encoding='UTF-8', checker=checker)) |
528 | 62 | return tests | 65 | return tests |