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