Skip to content

Commit

Permalink
TST: simpler check for unicode literals (ipython#790)
Browse files Browse the repository at this point in the history
check using isinstance instead for the length of the string
  • Loading branch information
olivierverdier committed Sep 15, 2011
1 parent 42e2485 commit 0ffa2ed
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions IPython/core/tests/test_interactiveshell.py
Expand Up @@ -138,11 +138,11 @@ def test_future_unicode(self):
"""Check that unicode_literals is imported from __future__ (gh #786)"""
ip = get_ipython()
try:
ip.run_cell(u'len_byte_str = len("\xe9")')
assert ip.user_ns['len_byte_str'] == 2
ip.run_cell(u'byte_str = "a"')
assert isinstance(ip.user_ns['byte_str'], str), 'string literals are byte strings by default'
ip.run_cell('from __future__ import unicode_literals')
ip.run_cell(u'len_unicode_str = len("\xe9")')
assert ip.user_ns['len_unicode_str'] == 1
ip.run_cell(u'unicode_str = "a"')
assert isinstance(ip.user_ns['unicode_str'], unicode), 'strings literals are now unicode'
finally:
# Reset compiler flags so we don't mess up other tests.
ip.compile.reset_compiler_flags()

0 comments on commit 0ffa2ed

Please sign in to comment.