Show More
@@ -1,67 +1,68 b'' | |||
|
1 | # coding: utf-8 | |
|
1 | 2 | """Tests for IPython.core.application""" |
|
2 | 3 | |
|
3 | 4 | import os |
|
4 | 5 | import tempfile |
|
5 | 6 | |
|
6 | 7 | from IPython.core.application import Application |
|
7 | 8 | |
|
8 | 9 | def test_unicode_cwd(): |
|
9 | 10 | """Check that IPython starts with non-ascii characters in the path.""" |
|
10 | wd = tempfile.mkdtemp(suffix="€") | |
|
11 | wd = tempfile.mkdtemp(suffix=u"€") | |
|
11 | 12 | |
|
12 | 13 | old_wd = os.getcwdu() |
|
13 | 14 | os.chdir(wd) |
|
14 | 15 | #raise Exception(repr(os.getcwd())) |
|
15 | 16 | try: |
|
16 | 17 | app = Application() |
|
17 | 18 | # The lines below are copied from Application.initialize() |
|
18 | 19 | app.create_default_config() |
|
19 | 20 | app.log_default_config() |
|
20 | 21 | app.set_default_config_log_level() |
|
21 | 22 | |
|
22 | 23 | # Find resources needed for filesystem access, using information from |
|
23 | 24 | # the above two |
|
24 | 25 | app.find_ipython_dir() |
|
25 | 26 | app.find_resources() |
|
26 | 27 | app.find_config_file_name() |
|
27 | 28 | app.find_config_file_paths() |
|
28 | 29 | |
|
29 | 30 | # File-based config |
|
30 | 31 | app.pre_load_file_config() |
|
31 | 32 | app.load_file_config(suppress_errors=False) |
|
32 | 33 | finally: |
|
33 | 34 | os.chdir(old_wd) |
|
34 | 35 | |
|
35 | 36 | def test_unicode_ipdir(): |
|
36 | 37 | """Check that IPython starts with non-ascii characters in the IP dir.""" |
|
37 | ipdir = tempfile.mkdtemp(suffix="€") | |
|
38 | ipdir = tempfile.mkdtemp(suffix=u"€") | |
|
38 | 39 | |
|
39 | 40 | # Create the config file, so it tries to load it. |
|
40 | 41 | with open(os.path.join(ipdir, 'ipython_config.py'), "w") as f: |
|
41 | 42 | pass |
|
42 | 43 | |
|
43 | 44 | old_ipdir1 = os.environ.pop("IPYTHONDIR", None) |
|
44 | 45 | old_ipdir2 = os.environ.pop("IPYTHON_DIR", None) |
|
45 | os.environ["IPYTHONDIR"] = ipdir | |
|
46 | os.environ["IPYTHONDIR"] = ipdir.encode("utf-8") | |
|
46 | 47 | try: |
|
47 | 48 | app = Application() |
|
48 | 49 | # The lines below are copied from Application.initialize() |
|
49 | 50 | app.create_default_config() |
|
50 | 51 | app.log_default_config() |
|
51 | 52 | app.set_default_config_log_level() |
|
52 | 53 | |
|
53 | 54 | # Find resources needed for filesystem access, using information from |
|
54 | 55 | # the above two |
|
55 | 56 | app.find_ipython_dir() |
|
56 | 57 | app.find_resources() |
|
57 | 58 | app.find_config_file_name() |
|
58 | 59 | app.find_config_file_paths() |
|
59 | 60 | |
|
60 | 61 | # File-based config |
|
61 | 62 | app.pre_load_file_config() |
|
62 | 63 | app.load_file_config(suppress_errors=False) |
|
63 | 64 | finally: |
|
64 | 65 | if old_ipdir1: |
|
65 | 66 | os.environ["IPYTHONDIR"] = old_ipdir1 |
|
66 | 67 | if old_ipdir2: |
|
67 | 68 | os.environ["IPYTHONDIR"] = old_ipdir2 |
General Comments 0
You need to be logged in to leave comments.
Login now