[issue3955] maybe doctest doesn't understand unicode_literals?
Matthis Thorade
report at bugs.python.org
Fri Feb 10 08:10:47 EST 2017
Matthis Thorade added the comment:
I found this bug when trying to write a doctest that passes on Python 3.5 and Python 2.7.9.
The following adapted example passes on Python2, but fails on Python3:
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
def f():
"""
>>> f()
u'xyz'
"""
return "xyz"
if __name__ == "__main__":
import doctest
doctest.testmod()
I think a nice solution could be to add a new directive so that I can use the following
def myUnic():
"""
This is a small demo that just returns a string.
>>> myUnic()
u'abc' # doctest: +ALLOW_UNICODE
"""
return 'abc'
I asked the same question here:
http://stackoverflow.com/questions/42158733/unicode-literals-and-doctest-in-python-2-7-and-python-3-5
----------
nosy: +Matthis Thorade
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3955>
_______________________________________
More information about the Python-bugs-list
mailing list