Merge lp:~cjwatson/lazr.restful/py3-doctest-encoding into lp:lazr.restful

Proposed by Colin Watson
Status: Merged
Merged at revision: 254
Proposed branch: lp:~cjwatson/lazr.restful/py3-doctest-encoding
Merge into: lp:lazr.restful
Diff against target: 89 lines (+22/-23)
3 files modified
src/lazr/restful/docs/utils.rst (+15/-16)
src/lazr/restful/docs/webservice-marshallers.rst (+6/-6)
src/lazr/restful/tests/test_docs.py (+1/-1)
To merge this branch: bzr merge lp:~cjwatson/lazr.restful/py3-doctest-encoding
Reviewer Review Type Date Requested Status
Ioana Lasc (community) Approve
Review via email: mp+389010@code.launchpad.net

Commit message

Set doctest encoding to UTF-8.

Description of the change

This allows us to write Unicode characters directly in doctests, which makes some tests more portable between Python 2 and 3.

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 'src/lazr/restful/docs/utils.rst'
2--- src/lazr/restful/docs/utils.rst 2020-02-04 11:52:59 +0000
3+++ src/lazr/restful/docs/utils.rst 2020-08-10 15:07:50 +0000
4@@ -330,22 +330,21 @@
5 quotation marks.
6
7 >>> from lazr.restful.utils import smartquote
8- >>> smartquote('')
9- u''
10- >>> smartquote('foo "bar" baz')
11- u'foo \u201cbar\u201d baz'
12- >>> smartquote('foo "bar baz')
13- u'foo \u201cbar baz'
14- >>> smartquote('foo bar" baz')
15- u'foo bar\u201d baz'
16- >>> smartquote('""foo " bar "" baz""')
17- u'""foo " bar "" baz""'
18- >>> smartquote('" foo "')
19- u'" foo "'
20- >>> smartquote('"foo".')
21- u'\u201cfoo\u201d.'
22- >>> smartquote('a lot of "foo"?')
23- u'a lot of \u201cfoo\u201d?'
24+ >>> print(smartquote(''))
25+ >>> print(smartquote('foo "bar" baz'))
26+ foo “bar” baz
27+ >>> print(smartquote('foo "bar baz'))
28+ foo “bar baz
29+ >>> print(smartquote('foo bar" baz'))
30+ foo bar” baz
31+ >>> print(smartquote('""foo " bar "" baz""'))
32+ ""foo " bar "" baz""
33+ >>> print(smartquote('" foo "'))
34+ " foo "
35+ >>> print(smartquote('"foo".'))
36+ “foo”.
37+ >>> print(smartquote('a lot of "foo"?'))
38+ a lot of “foo”?
39
40 safe_js_escape()
41 ================
42
43=== modified file 'src/lazr/restful/docs/webservice-marshallers.rst'
44--- src/lazr/restful/docs/webservice-marshallers.rst 2020-08-04 11:54:09 +0000
45+++ src/lazr/restful/docs/webservice-marshallers.rst 2020-08-10 15:07:50 +0000
46@@ -56,8 +56,8 @@
47 'foo'
48 >>> marshaller.marshall_from_json_data(4)
49 4
50- >>> marshaller.marshall_from_json_data(u"unicode\u2122")
51- u'unicode\u2122'
52+ >>> print(marshaller.marshall_from_json_data(u"unicode\u2122"))
53+ unicode™
54 >>> marshaller.marshall_from_json_data("")
55 ''
56 >>> print(marshaller.marshall_from_json_data(None))
57@@ -499,8 +499,8 @@
58
59 Note that the marshaller accepts character values where bit 7 is set.
60
61- >>> marshaller.marshall_from_json_data(u'int\xe9ressant')
62- u'int\xe9ressant'
63+ >>> print(marshaller.marshall_from_json_data(u'int\xe9ressant'))
64+ intéressant
65
66 Non-string values like floats are rejected.
67
68@@ -525,8 +525,8 @@
69 u'True'
70 >>> marshaller.marshall_from_request('')
71 u''
72- >>> marshaller.marshall_from_request(u'int\xe9ressant')
73- u'int\xe9ressant'
74+ >>> print(marshaller.marshall_from_request(u'int\xe9ressant'))
75+ intéressant
76 >>> marshaller.marshall_from_request('1.0')
77 u'1.0'
78
79
80=== modified file 'src/lazr/restful/tests/test_docs.py'
81--- src/lazr/restful/tests/test_docs.py 2020-02-04 11:52:59 +0000
82+++ src/lazr/restful/tests/test_docs.py 2020-08-10 15:07:50 +0000
83@@ -58,5 +58,5 @@
84 }
85 tests.addTest(doctest.DocFileSuite(
86 *doctest_files, module_relative=False, optionflags=DOCTEST_FLAGS,
87- tearDown=tearDown, globs=globs))
88+ tearDown=tearDown, globs=globs, encoding='UTF-8'))
89 return tests

Subscribers

People subscribed via source and target branches