From 42e248556aeaf92b9b5c285fea0c2c277e66b2cc 2011-09-14 05:45:50 From: Olivier Verdier Date: 2011-09-14 05:45:50 Subject: [PATCH] TST: add future unicode_literals test (#786) --- diff --git a/IPython/core/tests/test_interactiveshell.py b/IPython/core/tests/test_interactiveshell.py index e40f624..fc300b8 100644 --- a/IPython/core/tests/test_interactiveshell.py +++ b/IPython/core/tests/test_interactiveshell.py @@ -133,3 +133,16 @@ class InteractiveShellTestCase(unittest.TestCase): finally: # Reset compiler flags so we don't mess up other tests. ip.compile.reset_compiler_flags() + + 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('from __future__ import unicode_literals') + ip.run_cell(u'len_unicode_str = len("\xe9")') + assert ip.user_ns['len_unicode_str'] == 1 + finally: + # Reset compiler flags so we don't mess up other tests. + ip.compile.reset_compiler_flags()