##// END OF EJS Templates
Don't rely upon traitlets copying self.config...
Min RK -
Show More
@@ -13,6 +13,7 b' object and then create the configurable objects, passing the config to them.'
13 # Distributed under the terms of the Modified BSD License.
13 # Distributed under the terms of the Modified BSD License.
14
14
15 import atexit
15 import atexit
16 from copy import deepcopy
16 import glob
17 import glob
17 import logging
18 import logging
18 import os
19 import os
@@ -447,7 +448,9 b' class BaseIPythonApplication(Application):'
447 if self.subapp is not None:
448 if self.subapp is not None:
448 # stop here if subapp is taking over
449 # stop here if subapp is taking over
449 return
450 return
450 cl_config = self.config
451 # save a copy of CLI config to re-load after config files
452 # so that it has highest priority
453 cl_config = deepcopy(self.config)
451 self.init_profile_dir()
454 self.init_profile_dir()
452 self.init_config_files()
455 self.init_config_files()
453 self.load_config_file()
456 self.load_config_file()
@@ -4,9 +4,15 b''
4 import os
4 import os
5 import tempfile
5 import tempfile
6
6
7 import nose.tools as nt
8
9 from traitlets import Unicode
10
7 from IPython.core.application import BaseIPythonApplication
11 from IPython.core.application import BaseIPythonApplication
8 from IPython.testing import decorators as dec
12 from IPython.testing import decorators as dec
9 from IPython.utils import py3compat
13 from IPython.utils import py3compat
14 from IPython.utils.tempdir import TemporaryDirectory
15
10
16
11 @dec.onlyif_unicode_paths
17 @dec.onlyif_unicode_paths
12 def test_unicode_cwd():
18 def test_unicode_cwd():
@@ -48,3 +54,21 b' def test_unicode_ipdir():'
48 os.environ["IPYTHONDIR"] = old_ipdir1
54 os.environ["IPYTHONDIR"] = old_ipdir1
49 if old_ipdir2:
55 if old_ipdir2:
50 os.environ["IPYTHONDIR"] = old_ipdir2
56 os.environ["IPYTHONDIR"] = old_ipdir2
57
58 def test_cli_priority():
59 with TemporaryDirectory() as td:
60
61 class TestApp(BaseIPythonApplication):
62 test = Unicode().tag(config=True)
63
64 # Create the config file, so it tries to load it.
65 with open(os.path.join(td, 'ipython_config.py'), "w") as f:
66 f.write("c.TestApp.test = 'config file'")
67
68 app = TestApp()
69 app.initialize(['--profile-dir', td])
70 nt.assert_equal(app.test, 'config file')
71 app = TestApp()
72 app.initialize(['--profile-dir', td, '--TestApp.test=cli'])
73 nt.assert_equal(app.test, 'cli')
74
General Comments 0
You need to be logged in to leave comments. Login now