##// END OF EJS Templates
support for unicode identifiers...
support for unicode identifiers This rewrites some of the regular expressions that are used to match Python identifiers, so that they are unicode compatible. In Python 3, identifiers can contain unicode characters as long as the first character is not numeric. Examples for the changes: • inputtransformer: ``` In [1]: π = 3.14 In [2]: π.is_integer? Object `is_integer` not found. ``` ---------- • namespace: ``` π.is_integ*? ``` or ``` In [1]: %psearch π.is_integ Python identifiers can only contain ascii characters. ``` ---------- • prefilter: ``` %autocall 1 φ = float get_ipython().prefilter("φ 3") # should be 'φ(3)', but returns 'φ 3' ``` ---------- • completerlib: If there is a file e.g. named `π.py` in the current directory, then ``` import IPython IPython.core.completerlib.module_list('.') # should contain module 'π' ```

File last commit:

r25094:59d93919
r25595:d9c0e690
Show More
test_logger.py
30 lines | 896 B | text/x-python | PythonLexer
Fernando Perez
Add missing encoding declaration to file with unicode in it.
r7115 # -*- coding: utf-8 -*-
Thomas Kluyver
Add test that, if we failed to open the log file, we don't try to write to it.
r3889 """Test IPython.core.logger"""
Thomas Kluyver
Add test for unicode in logging.
r7082 import os.path
Thomas Kluyver
Add test that, if we failed to open the log file, we don't try to write to it.
r3889 import nose.tools as nt
Thomas Kluyver
Add test for unicode in logging.
r7082 from IPython.utils.tempdir import TemporaryDirectory
Thomas Kluyver
Add test that, if we failed to open the log file, we don't try to write to it.
r3889
def test_logstart_inaccessible_file():
try:
_ip.logger.logstart(logfname="/") # Opening that filename will fail.
except IOError:
pass
else:
nt.assert_true(False) # The try block should never pass.
try:
_ip.run_cell("a=1") # Check it doesn't try to log this
finally:
_ip.logger.log_active = False # If this fails, don't let later tests fail
Thomas Kluyver
Add test for unicode in logging.
r7082
def test_logstart_unicode():
with TemporaryDirectory() as tdir:
logfname = os.path.join(tdir, "test_unicode.log")
_ip.run_cell("'abc€'")
try:
_ip.magic("logstart -to %s" % logfname)
_ip.run_cell("'abc€'")
finally:
_ip.logger.logstop()