Skip to content

Commit

Permalink
mgr/cephadm: make remote_executables test able to handle ast.BinOp
Browse files Browse the repository at this point in the history
Was adding a line to serve.py that did

if ((datetime_now() - t).total_seconds() < 60)

and this was causing the remote_executables test to fail with

ValueError: _names: unexpected type: <ast.BinOp object at 0x7f0985c8d670>

where it seems the (datetime_now() - t) was resolving to an
ast.BinOp node which had no case in _names.

This patch makes it so the remote_executables test can also
handle these BinOp nodes and the binary operations that
could be within the node

Signed-off-by: Adam King <adking@redhat.com>
  • Loading branch information
adk3798 committed Apr 22, 2024
1 parent 2f31a48 commit d28aabd
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/pybind/mgr/cephadm/tests/test_remote_executables.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,24 @@ def _names(node):
return [f"<JoinedStr: {node.values!r}>"]
if isinstance(node, ast.Subscript):
return [f"<Subscript: {node.value}{node.slice}>"]
if isinstance(node, ast.BinOp):
return [f"<BinaryOp: {_names(node.left)} {_names(node.op)} {_names(node.right)}"]
if (
isinstance(node, ast.Add)
or isinstance(node, ast.Sub)
or isinstance(node, ast.Mult)
or isinstance(node, ast.Div)
or isinstance(node, ast.FloorDiv)
or isinstance(node, ast.Mod)
or isinstance(node, ast.Pow)
or isinstance(node, ast.LShift)
or isinstance(node, ast.RShift)
or isinstance(node, ast.ButOr)
or isinstance(node, ast.BitXor)
or isinstance(node, ast.BitAnd)
or isinstance(node, ast.MatMult)
):
return [repr(node)]
raise ValueError(f"_names: unexpected type: {node}")


Expand Down

0 comments on commit d28aabd

Please sign in to comment.