##// END OF EJS Templates
IPython behaves properly when started in a directory with non-ascii characters in the name. + Unit test....
Thomas Kluyver -
Show More
@@ -0,0 +1,33 b''
1 """Tests for IPython.core.application"""
2
3 import os
4 import tempfile
5
6 from IPython.core.application import Application
7
8 def test_unicode_cwd():
9 """Check that IPython can start with unicode characters in the path."""
10 wd = tempfile.mkdtemp(suffix="€")
11
12 old_wd = os.getcwdu()
13 os.chdir(wd)
14 #raise Exception(repr(os.getcwd()))
15 try:
16 app = Application()
17 # The lines below are copied from Application.initialize()
18 app.create_default_config()
19 app.log_default_config()
20 app.set_default_config_log_level()
21
22 # Find resources needed for filesystem access, using information from
23 # the above two
24 app.find_ipython_dir()
25 app.find_resources()
26 app.find_config_file_name()
27 app.find_config_file_paths()
28
29 # File-based config
30 app.pre_load_file_config()
31 app.load_file_config(suppress_errors=False)
32 finally:
33 os.chdir(old_wd)
@@ -350,13 +350,13 b' class Application(object):'
350 # our shipped copies of builtin profiles even if they don't have them
350 # our shipped copies of builtin profiles even if they don't have them
351 # in their local ipython directory.
351 # in their local ipython directory.
352 prof_dir = os.path.join(get_ipython_package_dir(), 'config', 'profile')
352 prof_dir = os.path.join(get_ipython_package_dir(), 'config', 'profile')
353 self.config_file_paths = (os.getcwd(), self.ipython_dir, prof_dir)
353 self.config_file_paths = (os.getcwdu(), self.ipython_dir, prof_dir)
354
354
355 def pre_load_file_config(self):
355 def pre_load_file_config(self):
356 """Do actions before the config file is loaded."""
356 """Do actions before the config file is loaded."""
357 pass
357 pass
358
358
359 def load_file_config(self):
359 def load_file_config(self, suppress_errors=True):
360 """Load the config file.
360 """Load the config file.
361
361
362 This tries to load the config file from disk. If successful, the
362 This tries to load the config file from disk. If successful, the
@@ -377,6 +377,8 b' class Application(object):'
377 self.config_file_name, exc_info=True)
377 self.config_file_name, exc_info=True)
378 self.file_config = Config()
378 self.file_config = Config()
379 except:
379 except:
380 if not suppress_errors: # For testing purposes
381 raise
380 self.log.warn("Error loading config file: %s" %
382 self.log.warn("Error loading config file: %s" %
381 self.config_file_name, exc_info=True)
383 self.config_file_name, exc_info=True)
382 self.file_config = Config()
384 self.file_config = Config()
@@ -293,9 +293,9 b' def test_parse_options():'
293
293
294 def test_dirops():
294 def test_dirops():
295 """Test various directory handling operations."""
295 """Test various directory handling operations."""
296 curpath = lambda :os.path.splitdrive(os.getcwd())[1].replace('\\','/')
296 curpath = lambda :os.path.splitdrive(os.getcwdu())[1].replace('\\','/')
297
297
298 startdir = os.getcwd()
298 startdir = os.getcwdu()
299 ipdir = _ip.ipython_dir
299 ipdir = _ip.ipython_dir
300 try:
300 try:
301 _ip.magic('cd "%s"' % ipdir)
301 _ip.magic('cd "%s"' % ipdir)
General Comments 0
You need to be logged in to leave comments. Login now