do not rewrite assertion if a message is present

This commit is contained in:
ed 2024-05-23 17:56:09 +02:00
parent cbf6bd9dd2
commit acbe63008d
1 changed files with 5 additions and 2 deletions

View File

@ -752,8 +752,11 @@ class AssertionRewriter(ast.NodeVisitor):
new: List[ast.AST] = []
for i, child in enumerate(field):
if isinstance(child, ast.Assert):
# Transform assert.
new.extend(self.visit(child))
# Transform assert if no message
if child.msg is None:
new.extend(self.visit(child))
else:
new.append(child)
else:
new.append(child)
if isinstance(child, ast.AST):