Show More
@@ -1,73 +1,70 b'' | |||
|
1 | 1 | # coding: utf-8 |
|
2 | 2 | """Tests for IPython.core.application""" |
|
3 | 3 | |
|
4 | 4 | import os |
|
5 | 5 | import tempfile |
|
6 | 6 | |
|
7 | import nose.tools as nt | |
|
8 | ||
|
9 | 7 | from traitlets import Unicode |
|
10 | 8 | |
|
11 | 9 | from IPython.core.application import BaseIPythonApplication |
|
12 | 10 | from IPython.testing import decorators as dec |
|
13 | 11 | from IPython.utils.tempdir import TemporaryDirectory |
|
14 | 12 | |
|
15 | 13 | |
|
16 | 14 | @dec.onlyif_unicode_paths |
|
17 | 15 | def test_unicode_cwd(): |
|
18 | 16 | """Check that IPython starts with non-ascii characters in the path.""" |
|
19 | 17 | wd = tempfile.mkdtemp(suffix=u"β¬") |
|
20 | 18 | |
|
21 | 19 | old_wd = os.getcwd() |
|
22 | 20 | os.chdir(wd) |
|
23 | 21 | #raise Exception(repr(os.getcwd())) |
|
24 | 22 | try: |
|
25 | 23 | app = BaseIPythonApplication() |
|
26 | 24 | # The lines below are copied from Application.initialize() |
|
27 | 25 | app.init_profile_dir() |
|
28 | 26 | app.init_config_files() |
|
29 | 27 | app.load_config_file(suppress_errors=False) |
|
30 | 28 | finally: |
|
31 | 29 | os.chdir(old_wd) |
|
32 | 30 | |
|
33 | 31 | @dec.onlyif_unicode_paths |
|
34 | 32 | def test_unicode_ipdir(): |
|
35 | 33 | """Check that IPython starts with non-ascii characters in the IP dir.""" |
|
36 | 34 | ipdir = tempfile.mkdtemp(suffix=u"β¬") |
|
37 | 35 | |
|
38 | 36 | # Create the config file, so it tries to load it. |
|
39 | 37 | with open(os.path.join(ipdir, 'ipython_config.py'), "w") as f: |
|
40 | 38 | pass |
|
41 | 39 | |
|
42 | 40 | old_ipdir1 = os.environ.pop("IPYTHONDIR", None) |
|
43 | 41 | old_ipdir2 = os.environ.pop("IPYTHON_DIR", None) |
|
44 | 42 | os.environ["IPYTHONDIR"] = ipdir |
|
45 | 43 | try: |
|
46 | 44 | app = BaseIPythonApplication() |
|
47 | 45 | # The lines below are copied from Application.initialize() |
|
48 | 46 | app.init_profile_dir() |
|
49 | 47 | app.init_config_files() |
|
50 | 48 | app.load_config_file(suppress_errors=False) |
|
51 | 49 | finally: |
|
52 | 50 | if old_ipdir1: |
|
53 | 51 | os.environ["IPYTHONDIR"] = old_ipdir1 |
|
54 | 52 | if old_ipdir2: |
|
55 | 53 | os.environ["IPYTHONDIR"] = old_ipdir2 |
|
56 | 54 | |
|
57 | 55 | def test_cli_priority(): |
|
58 | 56 | with TemporaryDirectory() as td: |
|
59 | 57 | |
|
60 | 58 | class TestApp(BaseIPythonApplication): |
|
61 | 59 | test = Unicode().tag(config=True) |
|
62 | 60 | |
|
63 | 61 | # Create the config file, so it tries to load it. |
|
64 | 62 | with open(os.path.join(td, 'ipython_config.py'), "w") as f: |
|
65 | 63 | f.write("c.TestApp.test = 'config file'") |
|
66 | 64 | |
|
67 | 65 | app = TestApp() |
|
68 |
app.initialize([ |
|
|
69 |
|
|
|
66 | app.initialize(["--profile-dir", td]) | |
|
67 | assert app.test == "config file" | |
|
70 | 68 | app = TestApp() |
|
71 |
app.initialize([ |
|
|
72 |
|
|
|
73 | ||
|
69 | app.initialize(["--profile-dir", td, "--TestApp.test=cli"]) | |
|
70 | assert app.test == "cli" |
General Comments 0
You need to be logged in to leave comments.
Login now