Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def run(self):
mcv = MockCheckVisitor(self.filename)
mcv.visit(self.tree)
for message in mcv.messages:
yield message
if isinstance(call_node, ast.Call):
func_info = FunctionNameFinder(self.filename)
func_info.visit(call_node)
# We are only looking at our patchers
if func_info.function_name not in self.patchers:
return
min_args = self.patchers[func_info.function_name]
if not find_autospec_keyword(call_node.keywords):
if len(call_node.args) < min_args:
self.messages.append(
(call_node.lineno, call_node.col_offset,
"H210 Missing 'autospec' or 'spec_set' keyword in "
"mock.patch/mock.patch.object", MockCheckVisitor)
)
def __init__(self, filename):
super(MockCheckVisitor, self).__init__()
self.messages = []
self.filename = filename