Test that loading config files does not override CLI options
(self)
| 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, |
nothing calls this directly
no test coverage detected