Skip to content

Commit 8d297b2

Browse files
committed
Add unit test
1 parent ae5c426 commit 8d297b2

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

tests/sample_with_prefix.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[tool.doit]
2+
optx = "6"
3+
opty = "7"
4+
5+
[tool.doit.plugins.command]
6+
foo = "tests.sample_plugin:MyCmd"
7+
8+
[tool.doit.commands.foo]
9+
nval = 33
10+
11+
[tool.doit.tasks.bar]
12+
opt = "baz"

tests/test_doit_cmd.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,19 @@ def test_merge_api_toml_config(self):
178178
assert main.config['foo'] == {'nval': 33}
179179
assert main.config['task:bar'] == {'opt': "baz"}
180180

181+
def test_merge_api_toml_config_with_prefix(self):
182+
config_filename = os.path.join(os.path.dirname(__file__), 'sample_with_prefix.toml')
183+
main = doit_cmd.DoitMain(config_filenames=config_filename,
184+
toml_config_files_prefix="tool.doit")
185+
assert 1 == len(main.config['COMMAND'])
186+
# test loaded plugin command is actually used with plugin name
187+
assert 'foo' in main.get_cmds()
188+
# INI has higher preference the api_config
189+
assert main.config['GLOBAL'] == {'optx':'6', 'opty':'7'}
190+
191+
assert main.config['foo'] == {'nval': 33}
192+
assert main.config['task:bar'] == {'opt': "baz"}
193+
181194

182195
def test_find_pyproject_toml_config(self):
183196
config_filename = os.path.join(os.path.dirname(__file__), 'pyproject.toml')

0 commit comments

Comments
 (0)