We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Defining a CmdAction with a positional argument leads to untestable task testing. For instance if we use the following minimal task
CmdAction
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.
action
missing 1 positional argument
doit/doit/action.py
Lines 148 to 156 in 83309d8
show_params
ref
args
normalize_callable
Lines 17 to 23 in 83309d8
Environment
Edit: added imports to minimal examples
The text was updated successfully, but these errors were encountered:
As a temporary solution one can skip the action property entirely and call the underlying _action directly, e.g.
_action
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}"
Sorry, something went wrong.
No branches or pull requests
Defining a
CmdAction
with a positional argument leads to untestable task testing.For instance if we use the following minimal task
and 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
.doit/doit/action.py
Lines 148 to 156 in 83309d8
Looking at the above
show_params
is called asref
on emptyargs
field due tonormalize_callable
not returning the correct signature.doit/doit/action.py
Lines 17 to 23 in 83309d8
Environment
Edit: added imports to minimal examples
The text was updated successfully, but these errors were encountered: