+ func: Callable[["TestPmdShell", int, Any, bool], None]
I'm thinking about this type. Sounds like there are too many conditions
that need to be satisfied. The problem is with the verify parameter. Do
we actually need it? If we're decorating a function, that may imply we
always want to verify the port stop/start. In which circumstance we
wouldn't want to verify that (the decorated function would need to not
verify what it's doing, but what function would that be and would we
actually want to not verify the port stop/start even then)?
I agree the parameter requirements are a little clunky and I played
with them for a while, but this one seemed the most "correct" to me.
We could create a policy that any method that is decorated with this
function must verify the port stopping and starting worked, but if we
did that I think you would have to also add to the policy that the
method being decorated must also always verify it was successful. I
don't think it makes sense to call a function and specify that you
don't want to verify success, and then still verify some component of
what the function is doing (starting and stopping ports in this case).
I think it would be fine to have this as a policy, but it's slightly
more limiting for users than other methods that testpmd shell offers.
I don't really know of an example when you wouldn't want to verify any
of the methods in TestpmdShell other than in case the developer is
expecting it to fail or it might not matter to the test if it was
successful or not for some reason. Considering we are already
following the path of optionally verifying all methods that can be
verified in the testpmd shell anyway, I didn't see the verify boolean
as anything extra for the methods to really have. We could instead
change to always verifying everything, but a change like that probably
doesn't fit the scope of this patch.
One more thing I've thought of which could be the best of both world is
to add the optional verify parameter to the decorator itself. That way
we could disable verification independently of whether the decorated
function does verification if need be. And the decorator would be less
coupled with the functions.