Defining a CmdAction
with a positional argument leads to untestable task testing.
For instance if we use the following minimal task
from doit.action import CmdAction
def task_pos_args():
def show_params(pos):
return f"echo {pos}"
return {
'actions':[CmdAction(show_params)],
'pos_arg': 'pos',
'verbosity': 2,
}
and write a test that calls the action with parametrized arguments
import pytest
@pytest.mark.parametrize("pos", ["arg", ["arg1", "arg2"]])
def test_pos_args(pos):
cmd_action = task_pos_args()["action"][0]
cmd = cmd_action.action().format(pos=pos)
assert cmd == f"echo {pos}"
will fail, because calling the action
property on a CmdAction
with a positional argument throws the error missing 1 positional argument
.
Lines 148 to 156 in 83309d8
show_params
is called as ref
on empty args
field due to normalize_callable
not returning the correct signature.Lines 17 to 23 in 83309d8
Environment
Edit: added imports to minimal examples
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too