From 773bd4c5449627f9971cb7437b9092bb8e7abca8 Mon Sep 17 00:00:00 2001 From: Thomas Kluyver Date: Wed, 30 May 2012 22:21:18 +0100 Subject: [PATCH] Add test for unicode in logging. --- IPython/core/logger.py | 4 ++-- IPython/core/tests/test_logger.py | 14 +++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/IPython/core/logger.py b/IPython/core/logger.py index 8a42dbaa200..56bc4d2a4d2 100644 --- a/IPython/core/logger.py +++ b/IPython/core/logger.py @@ -62,8 +62,8 @@ def _get_mode(self): logmode = property(_get_mode,_set_mode) - def logstart(self,logfname=None,loghead=None,logmode=None, - log_output=False,timestamp=False,log_raw_input=False): + def logstart(self, logfname=None, loghead=None, logmode=None, + log_output=False, timestamp=False, log_raw_input=False): """Generate a new log-file with a default header. Raises RuntimeError if the log has already been started""" diff --git a/IPython/core/tests/test_logger.py b/IPython/core/tests/test_logger.py index 9b340e9f78c..7ac76611fb9 100644 --- a/IPython/core/tests/test_logger.py +++ b/IPython/core/tests/test_logger.py @@ -1,6 +1,9 @@ """Test IPython.core.logger""" +import os.path + import nose.tools as nt +from IPython.utils.tempdir import TemporaryDirectory _ip = get_ipython() @@ -16,4 +19,13 @@ def test_logstart_inaccessible_file(): _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 - + +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()