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
=== modified file 'src/lazr/restful/docs/utils.rst'
--- src/lazr/restful/docs/utils.rst 2020-02-04 11:52:59 +0000
+++ src/lazr/restful/docs/utils.rst 2020-08-10 15:07:50 +0000
@@ -330,22 +330,21 @@
330quotation marks.330quotation marks.
331331
332 >>> from lazr.restful.utils import smartquote332 >>> from lazr.restful.utils import smartquote
333 >>> smartquote('')333 >>> print(smartquote(''))
334 u''334 >>> print(smartquote('foo "bar" baz'))
335 >>> smartquote('foo "bar" baz')335 foo “bar” baz
336 u'foo \u201cbar\u201d baz'336 >>> print(smartquote('foo "bar baz'))
337 >>> smartquote('foo "bar baz')337 foo “bar baz
338 u'foo \u201cbar baz'338 >>> print(smartquote('foo bar" baz'))
339 >>> smartquote('foo bar" baz')339 foo bar” baz
340 u'foo bar\u201d baz'340 >>> print(smartquote('""foo " bar "" baz""'))
341 >>> smartquote('""foo " bar "" baz""')341 ""foo " bar "" baz""
342 u'""foo " bar "" baz""'342 >>> print(smartquote('" foo "'))
343 >>> smartquote('" foo "')343 " foo "
344 u'" foo "'344 >>> print(smartquote('"foo".'))
345 >>> smartquote('"foo".')345 “foo”.
346 u'\u201cfoo\u201d.'346 >>> print(smartquote('a lot of "foo"?'))
347 >>> smartquote('a lot of "foo"?')347 a lot of “foo”?
348 u'a lot of \u201cfoo\u201d?'
349348
350safe_js_escape()349safe_js_escape()
351================350================
352351
=== modified file 'src/lazr/restful/docs/webservice-marshallers.rst'
--- src/lazr/restful/docs/webservice-marshallers.rst 2020-08-04 11:54:09 +0000
+++ src/lazr/restful/docs/webservice-marshallers.rst 2020-08-10 15:07:50 +0000
@@ -56,8 +56,8 @@
56 'foo'56 'foo'
57 >>> marshaller.marshall_from_json_data(4)57 >>> marshaller.marshall_from_json_data(4)
58 458 4
59 >>> marshaller.marshall_from_json_data(u"unicode\u2122")59 >>> print(marshaller.marshall_from_json_data(u"unicode\u2122"))
60 u'unicode\u2122'60 unicode™
61 >>> marshaller.marshall_from_json_data("")61 >>> marshaller.marshall_from_json_data("")
62 ''62 ''
63 >>> print(marshaller.marshall_from_json_data(None))63 >>> print(marshaller.marshall_from_json_data(None))
@@ -499,8 +499,8 @@
499499
500Note that the marshaller accepts character values where bit 7 is set.500Note that the marshaller accepts character values where bit 7 is set.
501501
502 >>> marshaller.marshall_from_json_data(u'int\xe9ressant')502 >>> print(marshaller.marshall_from_json_data(u'int\xe9ressant'))
503 u'int\xe9ressant'503 intéressant
504504
505Non-string values like floats are rejected.505Non-string values like floats are rejected.
506506
@@ -525,8 +525,8 @@
525 u'True'525 u'True'
526 >>> marshaller.marshall_from_request('')526 >>> marshaller.marshall_from_request('')
527 u''527 u''
528 >>> marshaller.marshall_from_request(u'int\xe9ressant')528 >>> print(marshaller.marshall_from_request(u'int\xe9ressant'))
529 u'int\xe9ressant'529 intéressant
530 >>> marshaller.marshall_from_request('1.0')530 >>> marshaller.marshall_from_request('1.0')
531 u'1.0'531 u'1.0'
532532
533533
=== modified file 'src/lazr/restful/tests/test_docs.py'
--- src/lazr/restful/tests/test_docs.py 2020-02-04 11:52:59 +0000
+++ src/lazr/restful/tests/test_docs.py 2020-08-10 15:07:50 +0000
@@ -58,5 +58,5 @@
58 }58 }
59 tests.addTest(doctest.DocFileSuite(59 tests.addTest(doctest.DocFileSuite(
60 *doctest_files, module_relative=False, optionflags=DOCTEST_FLAGS,60 *doctest_files, module_relative=False, optionflags=DOCTEST_FLAGS,
61 tearDown=tearDown, globs=globs))61 tearDown=tearDown, globs=globs, encoding='UTF-8'))
62 return tests62 return tests

Subscribers

People subscribed via source and target branches