Open mlkoenig opened 2 years ago
As a temporary solution one can skip the action
property entirely and call the underlying _action
directly, e.g.
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(pos)
assert cmd == f"echo {pos}"
Defining a
CmdAction
with a positional argument leads to untestable task testing. For instance if we use the following minimal taskand write a test that calls the action with parametrized arguments
will fail, because calling the
action
property on aCmdAction
with a positional argument throws the errormissing 1 positional argument
. https://github.com/pydoit/doit/blob/83309d81a7eb6dda30b9d04a05dd99a2de44192b/doit/action.py#L148-L156 Looking at the aboveshow_params
is called asref
on emptyargs
field due tonormalize_callable
not returning the correct signature. https://github.com/pydoit/doit/blob/83309d81a7eb6dda30b9d04a05dd99a2de44192b/doit/action.py#L17-L23Environment
Edit: added imports to minimal examples