From 09f65b2dc3a9f3c39700128b9b8284b03f839092 Mon Sep 17 00:00:00 2001 From: lilydjwg Date: Fri, 28 Feb 2020 15:57:59 +0800 Subject: [PATCH] add a test for cmd with % --- tests/conftest.py | 5 ++++- tests/test_cmd.py | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index 1763d01..bddf44a 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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] diff --git a/tests/test_cmd.py b/tests/test_cmd.py index 336f126..326f33d 100644 --- a/tests/test_cmd.py +++ b/tests/test_cmd.py @@ -1,6 +1,7 @@ # MIT licensed # Copyright (c) 2013-2017 lilydjwg , 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 +