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

TST: add future unicode_literals test (#786) #790

Merged
merged 3 commits into from Sep 15, 2011

Conversation

olivierverdier
Copy link
Contributor

add simple test to check that the bug #786 is indeed fixed in master

@takluyver
Copy link
Member

I'm not quite sure if this is reliably cross-platform. On Windows, \xe9 may be equivalent to the single byte \xe9 (although due to limitations in Python, it may not be). Can we use an isinstance test instead of len?

Also, we're aiming for Python 3 compatibility for 0.12, so we need to be careful with this test. We probably need to add a skipif_python3 decorator for this. Have a look at IPython.testing.decorators (or I can add that, if you prefer).

check using isinstance instead for the length of the string
@olivierverdier
Copy link
Contributor Author

Ok, I used isinstance instead of length, which is indeed more elegant. I'm not sure how to skip the test in Python 3, so I let you do that.

@takluyver
Copy link
Member

Great, thanks, that's definitely neater. In fact, I think it would now pass after conversion to Python 3, but I'll probably add a decorator to skip it anyway.

One minor niggle: the second argument to assert is the message that shows up if the assertion fails, and you've worded it as a description of what happens if it passes. I think it makes more sense for the message to say what went wrong, e.g.

assert isinstance(ip.user_ns['unicode_str'], unicode), 'strings literals are not being interpreted as unicode'

remove ambiguous assert messages for unicode_literals test
@olivierverdier
Copy link
Contributor Author

ok, you're right about the assert message. Since I find it a bit awkward, I remove them altogether.

takluyver added a commit that referenced this pull request Sep 15, 2011
TST: add future unicode_literals test (#786)
@takluyver takluyver merged commit 54e67c3 into ipython:master Sep 15, 2011
@takluyver
Copy link
Member

Excellent. Thanks, Olivier - it's merged.

mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
check using isinstance instead for the length of the string
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
remove ambiguous assert messages for unicode_literals test
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants