Format: text/x-python
⬇ Download File (788 B)
   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  def test_logstart_unicode():
  20      with TemporaryDirectory() as tdir:
  21          logfname = os.path.join(tdir, "test_unicode.log")
  22          _ip.run_cell("'abc€'")
  23          try:
  24              _ip.run_line_magic("logstart", "-to %s" % logfname)
  25              _ip.run_cell("'abc€'")
  26          finally:
  27              _ip.logger.logstop()
  28