Skip to content

Add support for unicode literals to #710

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

Closed
pytestbot opened this issue Apr 4, 2015 · 11 comments
Closed

Add support for unicode literals to #710

pytestbot opened this issue Apr 4, 2015 · 11 comments
Labels
good first issue easy issue that is friendly to new contributor plugin: doctests related to the doctests builtin plugin type: enhancement new feature or API change, should be merged into features branch

Comments

@pytestbot
Copy link
Contributor

Originally reported by: Jason R. Coombs (BitBucket: jaraco, GitHub: jaraco)


I like to use doctests for some use cases, and pytest makes inclusion of them in tests suites quite elegant.

However, doctests have a particularly hard problem with Python2/3 compatibility (because unicode strings render as u'' in Python 2 and '' in Python 3).

The NLTK project has built a nose plugin to better support the disparity.

I'd like to see pytest support this functionality as well.


@pytestbot
Copy link
Contributor Author

Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42):


If i am not mistaken, most current core committers do not use doctests much so you might consider adding necessary support yourself. Or maybe @charles or @HolgerPeters who did some relatively recent PR to the pytest doctest code can help.

@pytestbot
Copy link
Contributor Author

Original comment by Jason R. Coombs (BitBucket: jaraco, GitHub: jaraco):


I hear that this project exists as a standalone package supporting the behavior. Perhaps it could be extended to be a pytest plugin.

@pytestbot
Copy link
Contributor Author

Original comment by Jason R. Coombs (BitBucket: jaraco, GitHub: jaraco):


I'm willing to offer a bounty for this feature. Would that pique any interest?

@pytestbot pytestbot added the type: enhancement new feature or API change, should be merged into features branch label Jun 15, 2015
@RonnyPfannschmidt
Copy link
Member

@jaraco this one got lost under the rug, is it still needed, it seems easy enough to hand to a new contributor at first glance (i hope im right at least)

@RonnyPfannschmidt RonnyPfannschmidt added the good first issue easy issue that is friendly to new contributor label Jul 25, 2015
@jaraco
Copy link
Contributor

jaraco commented Jul 25, 2015

It is still needed. I regularly have to massage my doctests to satisfy Python 2 or just let them fail on Python 2. This one issue creates a great deal of impedance for doctest authors, and if it could be addressed in the test runner, that would be such a delight.

@dimazest
Copy link

I'm using pytest to execute NLTK tests.
I'm I right, that the core part is the _UnicodeOutputChecker (see NLTK nose plugin referenced earlier). What would be the best way to replace the default one with this?

@RonnyPfannschmidt
Copy link
Member

as far as i can tell, all core developers would have to investigate this first

@dimazest
Copy link

It seems so. Just rising the awareness about this issue!

nicoddemus added a commit to nicoddemus/pytest that referenced this issue Aug 13, 2015
When enabled, the ``u`` prefix is stripped from unicode strings in
expected doctest output. This allows doctests which use unicode
to run in Python 2 and 3 unchanged.

Fix pytest-dev#710
nicoddemus added a commit to nicoddemus/pytest that referenced this issue Aug 13, 2015
When enabled, the ``u`` prefix is stripped from unicode strings in
expected doctest output. This allows doctests which use unicode
to run in Python 2 and 3 unchanged.

Fix pytest-dev#710
@nicoddemus
Copy link
Member

Opened a PR at #938.

The use case I used was:

>>> b'12'.decode('ascii')
'12'

You guys feel that is enough?

@jaraco
Copy link
Contributor

jaraco commented Aug 13, 2015

@nicoddemus So awesome you're working this! I believe the use case should be sufficient.

@RonnyPfannschmidt
Copy link
Member

im under the impression the solution is to the spot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue easy issue that is friendly to new contributor plugin: doctests related to the doctests builtin plugin type: enhancement new feature or API change, should be merged into features branch
Projects
None yet
Development

No branches or pull requests

6 participants