##// END OF EJS Templates
Python vs IPython: recommend %cd, %env over !cd, !export...
Python vs IPython: recommend %cd, %env over !cd, !export The quick overview mentioned `!cd DIR` among examples of shell commands one might use —but that doesn't work as user would hope (can only affect commands in same ! e.g. `!cd /; pwd`). That's not as bad now that `!cd` prints a warning, but IMHO better to provide the right mental model up front. => Replaced that with minimal motivation why `!cd` and `!export` can't work, recommending some %magic alternatives; moved it out of examples to not distract, and right before Magics section.

File last commit:

r28944:f42bfc84
r29043:9b6f0ea1
Show More
test_logger.py
27 lines | 788 B | text/x-python | PythonLexer
# -*- coding: utf-8 -*-
"""Test IPython.core.logger"""
import os.path
import pytest
from tempfile import TemporaryDirectory
def test_logstart_inaccessible_file():
with pytest.raises(IOError):
_ip.logger.logstart(logfname="/") # Opening that filename will fail.
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
def test_logstart_unicode():
with TemporaryDirectory() as tdir:
logfname = os.path.join(tdir, "test_unicode.log")
_ip.run_cell("'abc€'")
try:
_ip.run_line_magic("logstart", "-to %s" % logfname)
_ip.run_cell("'abc€'")
finally:
_ip.logger.logstop()