add a test for cmd with %

This commit is contained in:
lilydjwg 2020-02-28 15:57:59 +08:00
parent 04101c11e0
commit 09f65b2dc3
2 changed files with 14 additions and 1 deletions

View File

@ -43,7 +43,10 @@ async def get_version():
async def __call__(name, config):
if isinstance(config, dict):
_config = configparser.ConfigParser(dict_type=dict, allow_no_value=True)
_config = configparser.ConfigParser(
dict_type=dict, allow_no_value=True,
interpolation=None,
)
_config.read_dict({name: config})
config = _config[name]

View File

@ -1,6 +1,7 @@
# MIT licensed
# Copyright (c) 2013-2017 lilydjwg <lilydjwg@gmail.com>, et al.
import time
import pytest
pytestmark = pytest.mark.asyncio
@ -9,3 +10,12 @@ async def test_cmd(get_version):
async def test_cmd_complex(get_version):
assert await get_version("example", {"cmd": "echo Meow | sed 's/meow/woof/i'"}) == "woof"
async def test_cmd_with_percent(run_source):
test_conf = '''\
[example]
cmd = date +%Y-%m-%d'''
date = await run_source(test_conf)
expected = time.strftime('%Y-%m-%d')
assert date == expected