diff --git a/tests/sample_with_prefix.toml b/tests/sample_with_prefix.toml new file mode 100644 index 00000000..c28a87b3 --- /dev/null +++ b/tests/sample_with_prefix.toml @@ -0,0 +1,12 @@ +[tool.doit] +optx = "6" +opty = "7" + +[tool.doit.plugins.command] +foo = "tests.sample_plugin:MyCmd" + +[tool.doit.commands.foo] +nval = 33 + +[tool.doit.tasks.bar] +opt = "baz" diff --git a/tests/test_doit_cmd.py b/tests/test_doit_cmd.py index e9c8323e..55f53500 100644 --- a/tests/test_doit_cmd.py +++ b/tests/test_doit_cmd.py @@ -178,6 +178,19 @@ def test_merge_api_toml_config(self): assert main.config['foo'] == {'nval': 33} assert main.config['task:bar'] == {'opt': "baz"} + def test_merge_api_toml_config_with_prefix(self): + config_filename = os.path.join(os.path.dirname(__file__), 'sample_with_prefix.toml') + main = doit_cmd.DoitMain(config_filenames=config_filename, + toml_config_files_prefix="tool.doit") + assert 1 == len(main.config['COMMAND']) + # test loaded plugin command is actually used with plugin name + assert 'foo' in main.get_cmds() + # INI has higher preference the api_config + assert main.config['GLOBAL'] == {'optx':'6', 'opty':'7'} + + assert main.config['foo'] == {'nval': 33} + assert main.config['task:bar'] == {'opt': "baz"} + def test_find_pyproject_toml_config(self): config_filename = os.path.join(os.path.dirname(__file__), 'pyproject.toml')