Merge lp:~cjwatson/lazr.restful/py3-normalize-doctests into lp:lazr.restful

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
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.renormalizing allows this to work reasonably cleanly. The only downside is that expected exception messages have to be written on a single line.

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
=== modified file 'setup.py'
--- setup.py 2020-02-13 00:01:12 +0000
+++ setup.py 2020-08-21 16:29:09 +0000
@@ -88,6 +88,7 @@
88 "Programming Language :: Python"],88 "Programming Language :: Python"],
89 extras_require=dict(89 extras_require=dict(
90 docs=['Sphinx'],90 docs=['Sphinx'],
91 test=['zope.testing>=4.6.0'],
91 xml=['lxml',] # requiring this of normal users is too much92 xml=['lxml',] # requiring this of normal users is too much
92 ),93 ),
93 test_suite='lazr.restful.tests',94 test_suite='lazr.restful.tests',
9495
=== modified file 'src/lazr/restful/docs/fields.rst'
--- src/lazr/restful/docs/fields.rst 2019-11-04 09:54:43 +0000
+++ src/lazr/restful/docs/fields.rst 2020-08-21 16:29:09 +0000
@@ -43,16 +43,18 @@
43But if the object isn't iterable, NotAContainer is raised.43But if the object isn't iterable, NotAContainer is raised.
4444
45 >>> int_collection.validate(object())45 >>> int_collection.validate(object())
46 ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
46 Traceback (most recent call last):47 Traceback (most recent call last):
47 ...48 ...
48 NotAContainer: <object...>49 zope.schema._bootstrapinterfaces.NotAContainer: <object...>
4950
50If the iterable contains an invalid item, WrongContainedType is raised.51If the iterable contains an invalid item, WrongContainedType is raised.
5152
52 >>> int_collection.validate(['a', 1, 2, 'b'])53 >>> int_collection.validate(['a', 1, 2, 'b'])
54 ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
53 Traceback (most recent call last):55 Traceback (most recent call last):
54 ...56 ...
55 WrongContainedType: ...57 zope.schema._bootstrapinterfaces.WrongContainedType: ...
5658
57=========59=========
58Reference60Reference
@@ -77,9 +79,10 @@
77 ... pass79 ... pass
78 >>> fake = Fake()80 >>> fake = Fake()
79 >>> reference.validate(fake)81 >>> reference.validate(fake)
82 ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
80 Traceback (most recent call last):83 Traceback (most recent call last):
81 ...84 ...
82 SchemaNotProvided: ...85 zope.schema._bootstrapinterfaces.SchemaNotProvided: ...
8386
84 >>> directlyProvides(fake, MySchema)87 >>> directlyProvides(fake, MySchema)
85 >>> reference.validate(fake)88 >>> reference.validate(fake)
@@ -92,9 +95,10 @@
9295
93 >>> fake.a_value = 'bad'96 >>> fake.a_value = 'bad'
94 >>> reference.validate(fake)97 >>> reference.validate(fake)
98 ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
95 Traceback (most recent call last):99 Traceback (most recent call last):
96 ...100 ...
97 ConstraintNotSatisfied...101 zope.schema._bootstrapinterfaces.ConstraintNotSatisfied: ...
98102
99 >>> fake.a_value = 'good'103 >>> fake.a_value = 'good'
100 >>> reference.validate(fake)104 >>> reference.validate(fake)
101105
=== modified file 'src/lazr/restful/docs/interface.rst'
--- src/lazr/restful/docs/interface.rst 2020-02-04 11:52:59 +0000
+++ src/lazr/restful/docs/interface.rst 2020-08-21 16:29:09 +0000
@@ -174,9 +174,10 @@
174raised:174raised:
175175
176 >>> copy_field(MyModel['age'], title='This should be unicode')176 >>> copy_field(MyModel['age'], title='This should be unicode')
177 ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
177 Traceback (most recent call last):178 Traceback (most recent call last):
178 ...179 ...
179 WrongType: ...180 zope.schema._bootstrapinterfaces.WrongType: ...
180181
181That function can only be called on an IField:182That function can only be called on an IField:
182183
183184
=== modified file 'src/lazr/restful/docs/multiversion.rst'
--- src/lazr/restful/docs/multiversion.rst 2020-02-04 13:17:32 +0000
+++ src/lazr/restful/docs/multiversion.rst 2020-08-21 16:29:09 +0000
@@ -412,9 +412,10 @@
412 >>> from zope.component import getAdapter412 >>> from zope.component import getAdapter
413413
414 >>> getAdapter(C1, IEntry)414 >>> getAdapter(C1, IEntry)
415 ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
415 Traceback (most recent call last):416 Traceback (most recent call last):
416 ...417 ...
417 ComponentLookupError: ...418 zope.interface.interfaces.ComponentLookupError: ...
418419
419When adapting Contact to IEntry you must provide a versioned request420When adapting Contact to IEntry you must provide a versioned request
420object. The IEntry object you get back will implement the appropriate421object. The IEntry object you get back will implement the appropriate
@@ -792,9 +793,10 @@
792793
793 >>> request = create_web_service_request('/1.0/contact_list')794 >>> request = create_web_service_request('/1.0/contact_list')
794 >>> resource = request.traverse(None)795 >>> resource = request.traverse(None)
796 ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
795 Traceback (most recent call last):797 Traceback (most recent call last):
796 ...798 ...
797 NotFound: Object: <PostBetaServiceRootResource...>, name: u'contact_list'799 zope.publisher.interfaces.NotFound: Object: <PostBetaServiceRootResource...>, name: ...'contact_list'
798800
799Here's the contact list under its correct URL.801Here's the contact list under its correct URL.
800802
@@ -845,9 +847,10 @@
845 >>> request_10 = create_web_service_request(847 >>> request_10 = create_web_service_request(
846 ... '/1.0/contacts/Cleo Python/fax')848 ... '/1.0/contacts/Cleo Python/fax')
847 >>> field = request_10.traverse(None)849 >>> field = request_10.traverse(None)
850 ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
848 Traceback (most recent call last):851 Traceback (most recent call last):
849 ...852 ...
850 NotFound: Object: <Contact object...>, name: u'fax'853 zope.publisher.interfaces.NotFound: Object: <Contact object...>, name: ...'fax'
851854
852We can invoke a named operation. Note that the name of the operation855We can invoke a named operation. Note that the name of the operation
853is now 'find' (it was 'findContacts' in 'beta'). And note that856is now 'find' (it was 'findContacts' in 'beta'). And note that
@@ -962,16 +965,18 @@
962 >>> request_beta = create_web_service_request(965 >>> request_beta = create_web_service_request(
963 ... '/dev/contacts/Cleo Python/fax')966 ... '/dev/contacts/Cleo Python/fax')
964 >>> field = request_beta.traverse(None)967 >>> field = request_beta.traverse(None)
968 ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
965 Traceback (most recent call last):969 Traceback (most recent call last):
966 ...970 ...
967 NotFound: Object: <Contact object...>, name: u'fax'971 zope.publisher.interfaces.NotFound: Object: <Contact object...>, name: ...'fax'
968972
969 >>> request_beta = create_web_service_request(973 >>> request_beta = create_web_service_request(
970 ... '/dev/contacts/Cleo Python/fax_number')974 ... '/dev/contacts/Cleo Python/fax_number')
971 >>> field = request_beta.traverse(None)975 >>> field = request_beta.traverse(None)
976 ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
972 Traceback (most recent call last):977 Traceback (most recent call last):
973 ...978 ...
974 NotFound: Object: <Contact object...>, name: u'fax_number'979 zope.publisher.interfaces.NotFound: Object: <Contact object...>, name: ...'fax_number'
975980
976We can invoke a named operation.981We can invoke a named operation.
977982
978983
=== modified file 'src/lazr/restful/docs/webservice-declarations.rst'
--- src/lazr/restful/docs/webservice-declarations.rst 2020-08-10 16:48:03 +0000
+++ src/lazr/restful/docs/webservice-declarations.rst 2020-08-21 16:29:09 +0000
@@ -2651,12 +2651,10 @@
2651explaining the problem.2651explaining the problem.
26522652
2653 >>> register_test_module('wrongorder', WrongOrderVersions)2653 >>> register_test_module('wrongorder', WrongOrderVersions)
2654 ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
2654 Traceback (most recent call last):2655 Traceback (most recent call last):
2655 ...2656 ...
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"...
2657 Annotations on "WrongOrderVersions.method" put an earlier version
2658 on top of a later version: "beta", "2.0", "1.0". The correct order
2659 is: "beta", "1.0", "2.0"...
26602658
2661Here's a class in which a named operation is removed in version 1.02659Here's a class in which a named operation is removed in version 1.0
2662and then annotated without being reinstated.2660and then annotated without being reinstated.
@@ -2673,11 +2671,10 @@
2673 ... """A method."""2671 ... """A method."""
26742672
2675 >>> register_test_module('annotatingremoved', AnnotatingARemovedMethod)2673 >>> register_test_module('annotatingremoved', AnnotatingARemovedMethod)
2674 ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
2676 Traceback (most recent call last):2675 Traceback (most recent call last):
2677 ...2676 ...
2678 ConfigurationExecutionError: ... Method "method" contains2677 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"...
2679 annotations for version "2.0", even though it's not published in
2680 that version. The bad annotations are: "as", "params"...
26812678
2682Mutators as named operations2679Mutators as named operations
2683----------------------------2680----------------------------
@@ -2745,9 +2742,10 @@
2745named operations.2742named operations.
27462743
2747 >>> operation_for(context, '2.0', 'set_value')2744 >>> operation_for(context, '2.0', 'set_value')
2745 ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
2748 Traceback (most recent call last):2746 Traceback (most recent call last):
2749 ...2747 ...
2750 ComponentLookupError: ...2748 zope.interface.interfaces.ComponentLookupError: ...
27512749
2752Here's an entry that defines a mutator method in version 2.0, after2750Here's an entry that defines a mutator method in version 2.0, after
2753the cutoff point.2751the cutoff point.
@@ -2777,14 +2775,16 @@
27772775
2778 >>> context = Mutator20()2776 >>> context = Mutator20()
2779 >>> operation_for(context, '1.0', 'set_value')2777 >>> operation_for(context, '1.0', 'set_value')
2778 ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
2780 Traceback (most recent call last):2779 Traceback (most recent call last):
2781 ...2780 ...
2782 ComponentLookupError: ...2781 zope.interface.interfaces.ComponentLookupError: ...
27832782
2784 >>> operation_for(context, '2.0', 'set_value')2783 >>> operation_for(context, '2.0', 'set_value')
2784 ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
2785 Traceback (most recent call last):2785 Traceback (most recent call last):
2786 ...2786 ...
2787 ComponentLookupError: ...2787 zope.interface.interfaces.ComponentLookupError: ...
27882788
2789Edge cases2789Edge cases
2790==========2790==========
@@ -2826,9 +2826,10 @@
2826defined yet.2826defined yet.
28272827
2828 >>> print(operation_for(context, 'beta', 'set_value').__class__.__name__)2828 >>> print(operation_for(context, 'beta', 'set_value').__class__.__name__)
2829 ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
2829 Traceback (most recent call last):2830 Traceback (most recent call last):
2830 ...2831 ...
2831 ComponentLookupError: ...2832 zope.interface.interfaces.ComponentLookupError: ...
28322833
2833The operation is available in both '1.0', and '2.0', even though2834The operation is available in both '1.0', and '2.0', even though
2834mutator operations aren't published as named operations after2835mutator operations aren't published as named operations after
@@ -2845,9 +2846,10 @@
2845a mutator.2846a mutator.
28462847
2847 >>> operation_for(context, '3.0', 'set_value')2848 >>> operation_for(context, '3.0', 'set_value')
2849 ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
2848 Traceback (most recent call last):2850 Traceback (most recent call last):
2849 ...2851 ...
2850 ComponentLookupError: ...2852 zope.interface.interfaces.ComponentLookupError: ...
28512853
2852But the mutator is active, as you can see by modifying the entry's field:2854But the mutator is active, as you can see by modifying the entry's field:
28532855
@@ -2958,9 +2960,10 @@
29582960
2959 >>> context = BetaMutator2()2961 >>> context = BetaMutator2()
2960 >>> operation_for(context, 'beta', 'set_value')2962 >>> operation_for(context, 'beta', 'set_value')
2963 ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
2961 Traceback (most recent call last):2964 Traceback (most recent call last):
2962 ...2965 ...
2963 ComponentLookupError: ...2966 zope.interface.interfaces.ComponentLookupError: ...
29642967
2965Getting the old behavior back2968Getting the old behavior back
2966-----------------------------2969-----------------------------
29672970
=== modified file 'src/lazr/restful/docs/webservice.rst'
--- src/lazr/restful/docs/webservice.rst 2020-08-17 11:46:51 +0000
+++ src/lazr/restful/docs/webservice.rst 2020-08-21 16:29:09 +0000
@@ -692,9 +692,10 @@
692 >>> verifyObject(IAuthorEntry, InvalidAuthorEntry(A1, request))692 >>> verifyObject(IAuthorEntry, InvalidAuthorEntry(A1, request))
693 True693 True
694 >>> IAuthorEntry.validateInvariants(InvalidAuthorEntry(A1, request))694 >>> IAuthorEntry.validateInvariants(InvalidAuthorEntry(A1, request))
695 ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
695 Traceback (most recent call last):696 Traceback (most recent call last):
696 ...697 ...
697 Invalid: InvalidAuthorEntry doesn't provide its ICookbookEntry schema.698 zope.interface.exceptions.Invalid: InvalidAuthorEntry doesn't provide its ICookbookEntry schema.
698699
699Other entries are defined similarly.700Other entries are defined similarly.
700701
@@ -1748,9 +1749,10 @@
1748 ... "Baked beans")1749 ... "Baked beans")
1749 >>> get_request = create_web_service_request(private_recipe_url)1750 >>> get_request = create_web_service_request(private_recipe_url)
1750 >>> recipe_resource = get_request.traverse(app)1751 >>> recipe_resource = get_request.traverse(app)
1752 ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
1751 Traceback (most recent call last):1753 Traceback (most recent call last):
1752 ...1754 ...
1753 Unauthorized: (<Recipe object...>, 'dish', ...)1755 zope.security.interfaces.Unauthorized: (<Recipe object...>, 'dish', ...)
17541756
1755The recipe will not show up in collections:1757The recipe will not show up in collections:
17561758
@@ -1858,10 +1860,10 @@
1858 >>> cover_url = quote('/beta/cookbooks/The Joy of Cooking/cover')1860 >>> cover_url = quote('/beta/cookbooks/The Joy of Cooking/cover')
1859 >>> get_request = create_web_service_request(cover_url)1861 >>> get_request = create_web_service_request(cover_url)
1860 >>> file_resource = get_request.traverse(app)1862 >>> file_resource = get_request.traverse(app)
1861 >>> file_resource()1863 >>> file_resource() # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
1862 Traceback (most recent call last):1864 Traceback (most recent call last):
1863 ...1865 ...
1864 NotFound: ... name: 'cover'1866 zope.publisher.interfaces.NotFound: ... name: 'cover'
18651867
1866 >>> print(C2.cover)1868 >>> print(C2.cover)
1867 None1869 None
@@ -1897,10 +1899,10 @@
18971899
1898 >>> get_request = create_web_service_request(cover_url)1900 >>> get_request = create_web_service_request(cover_url)
1899 >>> file_resource = get_request.traverse(app)1901 >>> file_resource = get_request.traverse(app)
1900 >>> file_resource()1902 >>> file_resource() # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
1901 Traceback (most recent call last):1903 Traceback (most recent call last):
1902 ...1904 ...
1903 NotFound: ... name: 'cover'1905 zope.publisher.interfaces.NotFound: ... name: 'cover'
19041906
1905 >>> print(C2.cover)1907 >>> print(C2.cover)
1906 None1908 None
@@ -1924,24 +1926,27 @@
1924Requesting a non-existent top-level collection:1926Requesting a non-existent top-level collection:
19251927
1926 >>> create_web_service_request('/beta/nosuchcollection').traverse(app)1928 >>> create_web_service_request('/beta/nosuchcollection').traverse(app)
1929 ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
1927 Traceback (most recent call last):1930 Traceback (most recent call last):
1928 ...1931 ...
1929 NotFound: ... name: u'nosuchcollection'1932 zope.publisher.interfaces.NotFound: ... name: ...'nosuchcollection'
19301933
1931Requesting a non-existent cookbook:1934Requesting a non-existent cookbook:
19321935
1933 >>> create_web_service_request('/beta/cookbooks/104').traverse(app)1936 >>> create_web_service_request('/beta/cookbooks/104').traverse(app)
1937 ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
1934 Traceback (most recent call last):1938 Traceback (most recent call last):
1935 ...1939 ...
1936 NotFound: ... name: u'104'1940 zope.publisher.interfaces.NotFound: ... name: ...'104'
19371941
1938Requesting a non-existent comment:1942Requesting a non-existent comment:
19391943
1940 >>> create_web_service_request(1944 >>> create_web_service_request(
1941 ... '/beta/cookbooks/The%20Joy%20of%20Cooking/comments/10').traverse(app)1945 ... '/beta/cookbooks/The%20Joy%20of%20Cooking/comments/10').traverse(app)
1946 ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
1942 Traceback (most recent call last):1947 Traceback (most recent call last):
1943 ...1948 ...
1944 NotFound: ... name: u'comments/10'1949 zope.publisher.interfaces.NotFound: ... name: ...'comments/10'
19451950
1946Manipulating entries1951Manipulating entries
1947====================1952====================
@@ -2108,9 +2113,10 @@
21082113
2109 >>> resource = create_web_service_request(2114 >>> resource = create_web_service_request(
2110 ... recipe_url, method='GET').traverse(app)2115 ... recipe_url, method='GET').traverse(app)
2116 ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
2111 Traceback (most recent call last):2117 Traceback (most recent call last):
2112 ...2118 ...
2113 NotFound: ... name: u'recipes/Foies de voilaille en aspic'2119 zope.publisher.interfaces.NotFound: ... name: ...'recipes/Foies de voilaille en aspic'
21142120
21152121
2116Within a template2122Within a template
21172123
=== modified file 'src/lazr/restful/example/base/tests/representation-cache.txt'
--- src/lazr/restful/example/base/tests/representation-cache.txt 2020-07-22 23:22:26 +0000
+++ src/lazr/restful/example/base/tests/representation-cache.txt 2020-08-21 16:29:09 +0000
@@ -13,9 +13,10 @@
13 >>> from zope.component import getUtility13 >>> from zope.component import getUtility
14 >>> from lazr.restful.interfaces import IRepresentationCache14 >>> from lazr.restful.interfaces import IRepresentationCache
15 >>> getUtility(IRepresentationCache)15 >>> getUtility(IRepresentationCache)
16 ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
16 Traceback (most recent call last):17 Traceback (most recent call last):
17 ...18 ...
18 ComponentLookupError: ...19 zope.interface.interfaces.ComponentLookupError: ...
1920
20DictionaryBasedRepresentationCache21DictionaryBasedRepresentationCache
21==================================22==================================
2223
=== modified file 'src/lazr/restful/example/base/tests/test_integration.py'
--- src/lazr/restful/example/base/tests/test_integration.py 2020-02-04 11:52:59 +0000
+++ src/lazr/restful/example/base/tests/test_integration.py 2020-08-21 16:29:09 +0000
@@ -12,6 +12,7 @@
12from pkg_resources import resource_filename12from pkg_resources import resource_filename
1313
14from van.testing.layer import zcml_layer, wsgi_intercept_layer14from van.testing.layer import zcml_layer, wsgi_intercept_layer
15from zope.testing import renormalizing
1516
16from lazr.restful.example.base.root import CookbookServiceRootResource17from lazr.restful.example.base.root import CookbookServiceRootResource
17from lazr.restful.testing.webservice import (18from lazr.restful.testing.webservice import (
@@ -28,6 +29,10 @@
28 doctest.NORMALIZE_WHITESPACE |29 doctest.NORMALIZE_WHITESPACE |
29 doctest.REPORT_NDIFF)30 doctest.REPORT_NDIFF)
3031
32
33checker = renormalizing.OutputChecker()
34
35
31class FunctionalLayer:36class FunctionalLayer:
32 allow_teardown = False37 allow_teardown = False
33 zcml = os.path.abspath(resource_filename('lazr.restful', 'ftesting.zcml'))38 zcml = os.path.abspath(resource_filename('lazr.restful', 'ftesting.zcml'))
@@ -52,7 +57,8 @@
52 'print_function': print_function,57 'print_function': print_function,
53 }58 }
54 suite = doctest.DocFileSuite(59 suite = doctest.DocFileSuite(
55 *doctest_files, optionflags=DOCTEST_FLAGS, globs=globs)60 *doctest_files, optionflags=DOCTEST_FLAGS, globs=globs,
61 checker=checker)
56 suite.layer = WSGILayer62 suite.layer = WSGILayer
57 tests.addTest(suite)63 tests.addTest(suite)
58 return tests64 return tests
5965
=== modified file 'src/lazr/restful/example/base/tests/traversal.txt'
--- src/lazr/restful/example/base/tests/traversal.txt 2009-09-01 13:10:07 +0000
+++ src/lazr/restful/example/base/tests/traversal.txt 2020-08-21 16:29:09 +0000
@@ -21,6 +21,7 @@
21error.21error.
2222
23 >>> container.publishTraverse(request, "nosuchname")23 >>> container.publishTraverse(request, "nosuchname")
24 ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
24 Traceback (most recent call last):25 Traceback (most recent call last):
25 ...26 ...
26 NotFound: ... name: 'nosuchname'27 zope.publisher.interfaces.NotFound: ... name: 'nosuchname'
2728
=== modified file 'src/lazr/restful/example/base_extended/tests/test_integration.py'
--- src/lazr/restful/example/base_extended/tests/test_integration.py 2020-02-04 11:52:59 +0000
+++ src/lazr/restful/example/base_extended/tests/test_integration.py 2020-08-21 16:29:09 +0000
@@ -12,12 +12,16 @@
12from pkg_resources import resource_filename12from pkg_resources import resource_filename
1313
14from van.testing.layer import zcml_layer, wsgi_intercept_layer14from van.testing.layer import zcml_layer, wsgi_intercept_layer
15from zope.testing import renormalizing
1516
16from lazr.restful.example.base.tests.test_integration import (17from lazr.restful.example.base.tests.test_integration import (
17 CookbookWebServiceTestPublication, DOCTEST_FLAGS)18 CookbookWebServiceTestPublication, DOCTEST_FLAGS)
18from lazr.restful.testing.webservice import WebServiceApplication19from lazr.restful.testing.webservice import WebServiceApplication
1920
2021
22checker = renormalizing.OutputChecker()
23
24
21class FunctionalLayer:25class FunctionalLayer:
22 allow_teardown = False26 allow_teardown = False
23 zcml = os.path.abspath(resource_filename(27 zcml = os.path.abspath(resource_filename(
@@ -40,7 +44,8 @@
40 'print_function': print_function,44 'print_function': print_function,
41 }45 }
42 suite = doctest.DocFileSuite(46 suite = doctest.DocFileSuite(
43 *doctest_files, optionflags=DOCTEST_FLAGS, globs=globs)47 *doctest_files, optionflags=DOCTEST_FLAGS, globs=globs,
48 checker=checker)
44 suite.layer = WSGILayer49 suite.layer = WSGILayer
45 tests.addTest(suite)50 tests.addTest(suite)
46 return tests51 return tests
4752
=== modified file 'src/lazr/restful/example/multiversion/tests/test_integration.py'
--- src/lazr/restful/example/multiversion/tests/test_integration.py 2020-02-04 11:52:59 +0000
+++ src/lazr/restful/example/multiversion/tests/test_integration.py 2020-08-21 16:29:09 +0000
@@ -11,8 +11,9 @@
11import doctest11import doctest
12from pkg_resources import resource_filename12from pkg_resources import resource_filename
1313
14from van.testing.layer import zcml_layer, wsgi_intercept_layer
14from zope.component import getUtility15from zope.component import getUtility
15from van.testing.layer import zcml_layer, wsgi_intercept_layer16from zope.testing import renormalizing
1617
17from lazr.restful.example.multiversion.root import (18from lazr.restful.example.multiversion.root import (
18 MultiversionWebServiceRootResource)19 MultiversionWebServiceRootResource)
@@ -27,6 +28,9 @@
27 doctest.REPORT_NDIFF)28 doctest.REPORT_NDIFF)
2829
2930
31checker = renormalizing.OutputChecker()
32
33
30class FunctionalLayer:34class FunctionalLayer:
31 zcml = os.path.abspath(resource_filename(35 zcml = os.path.abspath(resource_filename(
32 'lazr.restful.example.multiversion', 'site.zcml'))36 'lazr.restful.example.multiversion', 'site.zcml'))
@@ -55,7 +59,8 @@
55 'print_function': print_function,59 'print_function': print_function,
56 }60 }
57 suite = doctest.DocFileSuite(61 suite = doctest.DocFileSuite(
58 *doctest_files, optionflags=DOCTEST_FLAGS, globs=globs)62 *doctest_files, optionflags=DOCTEST_FLAGS, globs=globs,
63 checker=checker)
59 suite.layer = WSGILayer64 suite.layer = WSGILayer
60 tests.addTest(suite)65 tests.addTest(suite)
61 return tests66 return tests
6267
=== modified file 'src/lazr/restful/example/wsgi/tests/test_integration.py'
--- src/lazr/restful/example/wsgi/tests/test_integration.py 2020-02-04 11:52:59 +0000
+++ src/lazr/restful/example/wsgi/tests/test_integration.py 2020-08-21 16:29:09 +0000
@@ -11,8 +11,9 @@
11import doctest11import doctest
12from pkg_resources import resource_filename12from pkg_resources import resource_filename
1313
14from van.testing.layer import zcml_layer, wsgi_intercept_layer
14from zope.component import getUtility15from zope.component import getUtility
15from van.testing.layer import zcml_layer, wsgi_intercept_layer16from zope.testing import renormalizing
1617
17from lazr.restful.example.wsgi.root import WSGIExampleWebServiceRootResource18from lazr.restful.example.wsgi.root import WSGIExampleWebServiceRootResource
18from lazr.restful.interfaces import IWebServiceConfiguration19from lazr.restful.interfaces import IWebServiceConfiguration
@@ -25,6 +26,10 @@
25 doctest.NORMALIZE_WHITESPACE |26 doctest.NORMALIZE_WHITESPACE |
26 doctest.REPORT_NDIFF)27 doctest.REPORT_NDIFF)
2728
29
30checker = renormalizing.OutputChecker()
31
32
28class FunctionalLayer:33class FunctionalLayer:
29 zcml = os.path.abspath(resource_filename(34 zcml = os.path.abspath(resource_filename(
30 'lazr.restful.example.wsgi', 'site.zcml'))35 'lazr.restful.example.wsgi', 'site.zcml'))
@@ -52,7 +57,8 @@
52 'print_function': print_function,57 'print_function': print_function,
53 }58 }
54 suite = doctest.DocFileSuite(59 suite = doctest.DocFileSuite(
55 *doctest_files, optionflags=DOCTEST_FLAGS, globs=globs)60 *doctest_files, optionflags=DOCTEST_FLAGS, globs=globs,
61 checker=checker)
56 suite.layer = WSGILayer62 suite.layer = WSGILayer
57 tests.addTest(suite)63 tests.addTest(suite)
58 return tests64 return tests
5965
=== modified file 'src/lazr/restful/tests/test_docs.py'
--- src/lazr/restful/tests/test_docs.py 2020-08-10 15:05:58 +0000
+++ src/lazr/restful/tests/test_docs.py 2020-08-21 16:29:09 +0000
@@ -27,7 +27,7 @@
27import os27import os
28from pkg_resources import (28from pkg_resources import (
29 resource_filename, resource_exists, resource_listdir, cleanup_resources)29 resource_filename, resource_exists, resource_listdir, cleanup_resources)
3030from zope.testing import renormalizing
31from zope.testing.cleanup import cleanUp31from zope.testing.cleanup import cleanUp
3232
3333
@@ -37,6 +37,9 @@
37 doctest.REPORT_NDIFF)37 doctest.REPORT_NDIFF)
3838
3939
40checker = renormalizing.OutputChecker()
41
42
40def tearDown(test):43def tearDown(test):
41 """Run registered clean-up function."""44 """Run registered clean-up function."""
42 cleanUp()45 cleanUp()
@@ -58,5 +61,5 @@
58 }61 }
59 tests.addTest(doctest.DocFileSuite(62 tests.addTest(doctest.DocFileSuite(
60 *doctest_files, module_relative=False, optionflags=DOCTEST_FLAGS,63 *doctest_files, module_relative=False, optionflags=DOCTEST_FLAGS,
61 tearDown=tearDown, globs=globs, encoding='UTF-8'))64 tearDown=tearDown, globs=globs, encoding='UTF-8', checker=checker))
62 return tests65 return tests

Subscribers

People subscribed via source and target branches