| 1 |
# -*- coding: utf-8 -*- |
| 2 |
"""Test IPython.core.logger""" |
| 3 |
|
| 4 |
import os.path |
| 5 |
|
| 6 |
import pytest |
| 7 |
from tempfile import TemporaryDirectory |
| 8 |
|
| 9 |
|
| 10 |
def test_logstart_inaccessible_file(): |
| 11 |
with pytest.raises(IOError): |
| 12 |
_ip.logger.logstart(logfname="/") # Opening that filename will fail. |
| 13 |
|
| 14 |
try: |
| 15 |
_ip.run_cell("a=1") # Check it doesn't try to log this |
| 16 |
finally: |
| 17 |
_ip.logger.log_active = False # If this fails, don't let later tests fail |
| 18 |
|
| 19 |
|
| 20 |
def test_logstart_unicode(): |
| 21 |
with TemporaryDirectory() as tdir: |
| 22 |
logfname = os.path.join(tdir, "test_unicode.log") |
| 23 |
_ip.run_cell("'abc€'") |
| 24 |
try: |
| 25 |
_ip.run_line_magic("logstart", "-to %s" % logfname) |
| 26 |
_ip.run_cell("'abc€'") |
| 27 |
finally: |
| 28 |
_ip.logger.logstop() |