Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added doctest encoding command line option #2101

Merged
merged 8 commits into from
Nov 30, 2016
12 changes: 6 additions & 6 deletions testing/test_doctest.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ def test_encoding_ascii(self, testdir):
def test_encoding_latin1(self, testdir):
"""Test support for --doctest-encoding option.
"""
testdir._makefile(".txt", ["""
>>> 'üäö'
'üäö'
testdir._makefile(".txt", [u"""
>>> len(u'üäö')
3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i propose making those a format string adding u in front of it for py2, and leaving it out for py3
that way the output can be tested

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Python 2, they will be formatted as escape sequences: u'\x84\x94\x81'. Probably I can just repr(value) to the files.

"""], {}, encoding='latin1')

result = testdir.runpytest("--doctest-encoding=latin1")
Expand All @@ -160,9 +160,9 @@ def test_encoding_latin1(self, testdir):
def test_encoding_utf8(self, testdir):
"""Test support for --doctest-encoding option.
"""
testdir.maketxtfile("""
>>> 'üäö'
'üäö'
testdir.maketxtfile(u"""
>>> len(u'üäö')
3
""")

result = testdir.runpytest()
Expand Down