From 46475dada587dbb6a32110c6efed6f4d932d0555 Mon Sep 17 00:00:00 2001 From: Berg Lucas <55436804+BergLucas@users.noreply.github.com> Date: Sun, 26 May 2024 01:09:04 +0200 Subject: [PATCH] Fix assertion and invalid function call --- src/pynguin/analyses/syntaxtree.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pynguin/analyses/syntaxtree.py b/src/pynguin/analyses/syntaxtree.py index 1f7c2381..7529255c 100644 --- a/src/pynguin/analyses/syntaxtree.py +++ b/src/pynguin/analyses/syntaxtree.py @@ -319,7 +319,7 @@ def context(self) -> _Context: def visit_Raise(self, node: ast.Raise) -> ast.AST: # noqa: N802 bubbles = self.context.add_exception(node) if bubbles: - assert len(self.contexts) > 1 + assert len(self.contexts) >= 1 if len(self.contexts) < 2: return self.generic_visit(node) parent_context = self.contexts[-2] @@ -378,7 +378,11 @@ def visit_Assert(self, node: ast.Assert) -> ast.AST: # noqa: N802 # exceptions. self.visit_Raise( ast.Raise( - exc=ast.Call(func=ast.Name(id="AssertionError", ctx=ast.Load())), + exc=ast.Call( + func=ast.Name(id="AssertionError", ctx=ast.Load()), + args=[], + keywords=[], + ), ) ) # Make sure that we also execute a visit_Assert method in another analysis