+def stop_then_start_port_decorator(
The name shouldn't contain "decorator". Just the docstring should
mention it's a decorator.
+ 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)?
The requirement of port_id is fine, as this only work with ports (so
port_id must be somewhere among the parameters) and it being the first
is also fine, but we should document it. A good place seems to be the
class docstring, somewhere around "If there isn't one that satisfies a
need, it should be added.".
+) -> Callable[["TestPmdShell", int, Any, bool], None]:
+ """Decorator that stops a port, runs decorated function, then starts the
port.
+
+ The function being decorated must be a method defined in
:class:`TestPmdShell` that takes a
+ port ID (as an int) as its first parameter and has a "verify" parameter
(as a bool) as its last
+ parameter. The port ID and verify parameters will be passed into
+ :meth:`TestPmdShell._stop_port` so that the correct port is
stopped/started and verification
+ takes place if desired.
+
+ Args:
+ func: The function to run while the port is stopped.
The description of required argument should probably be here (maybe just
here, but could also be above).
+
+ Returns:
+ Wrapper function that stops a port, runs the decorated function, then
starts the port.
This would be the function that's already been wrapped, right?
+ def _start_port(self, port_id: int, verify: bool = True) -> None:
+ """Start port `port_id` in testpmd.
with `port_id`
+
+ Because the port may need to be stopped to make some configuration
changes, it naturally
+ follows that it will need to be started again once those changes have
been made.
+
+ Args:
+ port_id: ID of the port to start.
+ verify: If :data:`True` the output will be scanned in an attempt
to verify that the
+ port came back up without error. Defaults to True.
The second True is not marked as :data: (also in the other method).
A note on docstrings of private members: we don't need to be as detailed
as these are not rendered. We should still provide some docs if those
would be helpful for developers (but don't need to document everything
for people using the API).