test_logger.py
31 lines
| 893 B
| text/x-python
|
PythonLexer
Thomas Kluyver
|
r3889 | """Test IPython.core.logger""" | ||
Thomas Kluyver
|
r7082 | import os.path | ||
Thomas Kluyver
|
r3889 | import nose.tools as nt | ||
Thomas Kluyver
|
r7082 | from IPython.utils.tempdir import TemporaryDirectory | ||
Thomas Kluyver
|
r3889 | |||
_ip = get_ipython() | ||||
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
|
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() | ||||