test_logger.py
27 lines
| 788 B
| text/x-python
|
PythonLexer
Fernando Perez
|
r7115 | # -*- coding: utf-8 -*- | ||
Thomas Kluyver
|
r3889 | """Test IPython.core.logger""" | ||
Thomas Kluyver
|
r7082 | import os.path | ||
Matthias Bussonnier
|
r27509 | |||
Tomasz Kłoczko
|
r26749 | import pytest | ||
Matthias Bussonnier
|
r27509 | from tempfile import TemporaryDirectory | ||
Thomas Kluyver
|
r7082 | |||
Thomas Kluyver
|
r3889 | |||
def test_logstart_inaccessible_file(): | ||||
Nikita Kniazev
|
r27087 | with pytest.raises(IOError): | ||
Thomas Kluyver
|
r3889 | _ip.logger.logstart(logfname="/") # Opening that filename will fail. | ||
Blazej Michalik
|
r26750 | |||
Thomas Kluyver
|
r3889 | 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: | ||||
M Bussonnier
|
r28944 | _ip.run_line_magic("logstart", "-to %s" % logfname) | ||
Thomas Kluyver
|
r7082 | _ip.run_cell("'abc€'") | ||
finally: | ||||
_ip.logger.logstop() | ||||