MCPcopy Create free account
hub / github.com/ipython/traitlets / test_cli_priority

Method test_cli_priority

tests/config/test_application.py:241–266  ·  view source on GitHub ↗

Test that loading config files does not override CLI options

(self)

Source from the content-addressed store, hash-verified

239 self.assertEqual(app.bar.enabled, False)
240
241 def test_cli_priority(self):
242 """Test that loading config files does not override CLI options"""
243 name = "config.py"
244
245 class TestApp(Application):
246 value = Unicode().tag(config=True)
247 config_file_loaded = Bool().tag(config=True)
248 aliases = {"v": "TestApp.value"}
249
250 app = TestApp()
251 with TemporaryDirectory() as td:
252 config_file = pjoin(td, name)
253 with open(config_file, "w") as f:
254 f.writelines(
255 ["c.TestApp.value = 'config file'\n", "c.TestApp.config_file_loaded = True\n"]
256 )
257
258 app.parse_command_line(["--v=cli"])
259 assert "value" in app.config.TestApp
260 assert app.config.TestApp.value == "cli"
261 assert app.value == "cli"
262
263 app.load_config_file(name, path=[td])
264 assert app.config_file_loaded
265 assert app.config.TestApp.value == "cli"
266 assert app.value == "cli"
267
268 def test_ipython_cli_priority(self):
269 # this test is almost entirely redundant with above,

Callers

nothing calls this directly

Calls 3

parse_command_lineMethod · 0.80
load_config_fileMethod · 0.80
TestAppClass · 0.70

Tested by

no test coverage detected